diff options
author | Federico Di Gregorio <fog@initd.org> | 2005-10-17 16:04:43 +0000 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2005-10-17 16:04:43 +0000 |
commit | a237209a5e20e1cb557acde1e797107597b2b85f (patch) | |
tree | 36d5de4a1516c16b610163c24fb545ce7e14af08 /examples/tz.py | |
parent | 206aa79225745815ad8cb46b059859baadd2cf5a (diff) | |
download | psycopg2-a237209a5e20e1cb557acde1e797107597b2b85f.tar.gz |
Default tzinfo_factory for cursors.
Diffstat (limited to 'examples/tz.py')
-rw-r--r-- | examples/tz.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/tz.py b/examples/tz.py index 0ae9fa3..8fe40af 100644 --- a/examples/tz.py +++ b/examples/tz.py @@ -51,7 +51,12 @@ curs.execute("INSERT INTO test_tz VALUES (%s)", (d,)) print "Inserted timestamp with timezone:", d print "Time zone:", d.tzinfo.tzname(d), "offset:", d.tzinfo.utcoffset(d) -curs.tzinfo_factory = FixedOffsetTimezone +curs.execute("SELECT * FROM test_tz") +d = curs.fetchone()[0] +curs.execute("INSERT INTO test_tz VALUES (%s)", (d,)) +print "Inserted SELECTed timestamp:", d +print "Time zone:", d.tzinfo.tzname(d), "offset:", d.tzinfo.utcoffset(d) + curs.execute("SELECT * FROM test_tz") for d in curs: u = d[0].utcoffset() or ZERO @@ -59,5 +64,6 @@ for d in curs: print "Local time:", d[0] print "Time zone:", d[0].tzinfo.tzname(d[0]), d[0].tzinfo.utcoffset(d[0]) + curs.execute("DROP TABLE test_tz") conn.commit() |