Re: [pysqlite] Timestamp adapter and timezone
Gerhard Häring <[email protected]> Wed, 11 Mar 2009 09:32:03 +0100
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Adrian Klaver wrote:
> Recently ran across a problem with moving a timestamp with timezone value from
> Postgres to sqlite. Seems the convert_timestamp function does not know what to
> do with the offset value. See below:
>
> File "/usr/lib/python2.5/sqlite3/dbapi2.py", line 71, in convert_timestamp
> microseconds = int(float("0." + timepart_full[1]) * 1000000)
> ValueError: invalid literal for float(): 0.610000-08:00
>
> Any suggestions are welcome.
You can write your own converters/adapters that support this.
http://oss.itsystementwicklung.de/download/pysqlite/doc/sqlite3.html#sqlite-and-python-types
What I suggest instead is to take a step back and think again how to
support multiple databases. Two things come to my mind:
- use an existing abstraction layer like SQLAlchemy (highly recommended)
- use the lowest common determinator and build your own (this can mean
using "normal" timestamps or switching to floats instead)
-- Gerhard