Roundtrip SQL data especially datetime

fumanchu fumanchu at amor.org
Sun Dec 17 10:59:32 EST 2006


dyork wrote:
> "Dennis Lee Bieber" <wlfraed at ix.netcom.com> wrote in message
> news:mailman.1686.1166257834.32031.python-list at python.org...
>
> > If you actually look at what the various DB-API adapters produce
> > when sending to the database engine, floats, bools, etc. are all sent as
> > string representations; about the only source for problems would be
> > involved in the number of significant digits transferred for a float
> > (you might feed 15 digits in, and only get 7 or 10 back)
>
> Having written adapters myself, I would not be confident that is true. It's
> convenient to use native formats for floats and ints, and strings for
> everything else. Regardless, you get trouble with (a) nulls (b) dates/times
> (c) decimal/currency (d) precision mismatches (e)  collation mismatches (f)
> blobs (g) Unicode (h) special values like NaN. It takes great attention to
> detail to be sure it all works, and I really don't want to write it (again).
>
> I'd just like to choose some product X and "It Just Works"!

Ah. Then feel free to have a look at Dejavu, wherein I've worked all
that out for you (okay, not NaN, but that wouldn't be hard).

A quick look over
http://projects.amor.org/dejavu/browser/trunk/storage/storemysql.py
shows proper string escaping, correct handling of 1/0 for True and
False, encoding, max precision, CURDATE, automatic scaling to BLOB
columns for bytes > 255, and BLOB index limitations. All of the Null,
date/time, decimal, unicode, and other type adaptation support is in
the generic
http://projects.amor.org/dejavu/browser/trunk/storage/geniusql.py

The same goes for Postgres, MS Access, SQLite, and SQL Server. Firebird
and sqlite3 are in the works.

Simple docs at http://projects.amor.org/docs/dejavu/


Robert Brewer
System Architect
Amor Ministries
fumanchu at amor.org




More information about the Python-list mailing list