Re: tzinfo

"James Henstridge" <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Tue, Dec 30, 2008 at 11:57 PM, jo <[email protected]> wrote:
> Hi all,
>
> I would like to know if there's a way to disable tzinfo from psycopg2.
>
> like this:
> datetime.datetime(2008, 12, 30, 15, 44, 31, 418607)
>
> instead of:
> datetime.datetime(2008, 12, 30, 15, 44, 31,
> 418607,tzinfo=<psycopg2.tz.FixedOffsetTimezone object at 0xbd33e4c>)

One way is to define your columns as "timestamp without time zone".
If the database doesn't return a time zone, then psycopg won't return
one either.

Alternatively, you can convert a time zone aware datetime to a naive
datetime with the following snippet:

    dt = dt.replace(tzinfo=None)

James.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.