B
B
beginer1232016-08-30 10:49:06
PostgreSQL
beginer123, 2016-08-30 10:49:06

Databases what type of field to choose?

Hello, I will have a field in which I will enter the timestamp in milliseconds, which will store the date the entry was added to the database
. I use postgres. To do this, when inserting ,
I use the following code in Python: he swears, says that the value of the field type is too large, I use Int

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rickkk, 2016-08-30
@Rickkk

Greetings!
Why insert a time value from Python? It is much more reliable that the DBMS itself sets the current timestamp when inserting a record into the table.
To do this, you just need to add the created_at field to the table with default now:

create table mytable 
(
...
created_at timestamp not null default now()
);

S
Sergey, 2016-08-30
Protko @Fesor

int(round(time.time() * 1000))
Somehow it doesn't look like milliseconds)
https://www.postgresql.org/docs/9.1/static/datatyp...
see the table and choose.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question