0

With PostgreSQL, one of my tables has an 'interval' column, values of which I would like to extract as something I can manipulate (datetime.timedelta?); however I am using PyGreSQL which seems to be returning intervals as strings, which is less than helpful.

Where should I be looking to either parse the interval or make PyGreSQL return it as a <something useful>?

Ellery Newcomer
  • 1,594
  • 1
  • 11
  • 23

1 Answers1

3

Use Psycopg 2. It correctly converts between Postgres's interval data type and Python's timedelta.

Kevin
  • 3,391
  • 5
  • 30
  • 40
  • Not really psycopg2 returns a timedelta of -1 day, 23 hour when you have a value of -1 hour interval in your postgresql table – sandino Apr 23 '14 at 20:54