cur.execute("SELECT \
title, \
body, \
date \ # This pgsql type is date
FROM \
table \
WHERE id = '%s';", id)
response = cur.fetchall()
print response
As an example this gives me: -
[('sample title', 'sample body', datetime.date(2012, 8, 5))]
Which can't be passed to things like json.dumps so I'm having to do this: -
processed = []
for row in response:
processed.append({'title' : row[0],
'body' : row[1],
'date' : str(row[2])
})
Which feels like poor form, does anyone know of a better way of handling this?