Hi,

Having just started looking at pygresql-5+ (python-2.7),
I have another question.

How do I suppress the conversion of timestamp with time zone values
from a string to a datetime.datetime object with a pgdb.timezone object 
as the tzinfo? I want to parse them myself and use my own choice of tzinfo.

Based on the changelog and looking at pgdb.py, I tried the following but
none of them worked:

  pgdb.set_typecast('timestamp', None)
  pgdb.set_typecast('timestamptz', None) # I expected this one to work
  pgdb.set_typecast('timestamp with time zone', None)

Here's what I tried:

  #!/usr/bin/env python
  import pgdb
  try: pgdb.set_typecast('timestamptz', None)
  except AttributeError: pass
  connection = pgdb.connect(host='XXX', database='XXX', user='XXX', 
password='XXX')
  cursor = connection.cursor()
  cursor.execute("select cast('2016-01-01 12:22:22+11' as timestamp with time 
zone)")
  rows = cursor.fetchall()
  print('%r' % rows[0][0])
  # pygresql-4.2.2 outputs '2016-01-01 12:22:22+11' (which then needs to be 
parsed)
  # pygresql-5.0.1 outputs datetime.datetime(2016, 1, 1, 12, 22, 22, 
tzinfo=<pgdb.timezone object at 0x11461f0>)

Any suggestions?

cheers,
raf

_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to