Erwin's answer is correct, I just want to address another aspect.
I am trying to store number of seconds since 1970 in the column
Please don't do that. It's annoying to query and is of no storage benefit over just using a timestamp.
Store timestamp without time zone
. Or, preferably, use timestamp with time zone
so it's properly adjusted for the TimeZone
setting of the client.
If the client app needs epoch seconds, it can always select extract(epoch from my_field), ...
. But really, your app should be able to consume dates properly anyway.
It isn't clear what problem you're attempting to solve in your application by switching to storing raw epoch seconds; there may be cases where you have to. But personally, rather than do something like this, I'd instead define an updatable view that returned epoch seconds and converted the input bigints into a timestamp for storage in the underlying table. So the application would think it had a table with epoch seconds, but it was really working with timestamps. Of course, I'd prefer to just make my app work with timestamps properly in the first place, converting to epoch seconds in the application if some client interface required it.
Update:
In your case, just insert a datetime.datetime
object.
import datetime
# Convert epoch seconds into a Python datetime.datetime object that psycopg2 will
# understand as a date and insert as a PostgreSQL timestamp value.
ts = datetime.datetime.fromtimestamp(d['timestamp'])
cursor.execute("INSERT into tablename columname VALUES (%s)", (ts,) )