I am using postgres and I have a table with a column whose data type is timestamp without time zone.
I would like to change the data type to bigint
. I am trying to store number of seconds since 1970 in the column. So something big like 1397597908756
.
I am using python, something like:
d = dict() # create a dictionary, has key 'timestamp'
#get data from server and store in array
d.update(dict(timestamp=data[1]) #data[1] has the number of seconds
I touch server many times so storing in dictionary is essential. The query is:
cursor.execute("INSERT into tablename columname VALUES (%s)", (quote['timestamp'];
At this point, an exception is thrown:
invalid input syntax for type timestamp: 1397597908756
So I tried to change the data type from timestamp without timezone
to bigint
. I did:
ALTER TABLE tablename ALTER COLUMN columnname
SET DATA TYPE bigint USING updated::bigint;
I got the following error:
ERROR: cannot cast type timestamp without time zone to bigint