Search code examples
pythonsqlpostgresqlpygresql

python sql interval


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>?


Solution

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