Home Error copying empty Timestamp fields with postgresql
Reply: 0

Error copying empty Timestamp fields with postgresql

Chiara Munari
1#
Chiara Munari Published in 2017-12-06 11:12:16Z

I have a postgres database called myDB. myDB have a table called myTable which has two timestamp fiels. So I have a csv file in which there are all the data and some data are NULL. In postgresql I've used

COPY myTable FROM '/path/to/file.csv' delimiter ';' csv;

postgresql doesn't take the NULL data that will be in the timestamp fields (while accepts NULL data that will be a integer or others).

>Error message is: ERROR:  invalid input syntax for type timestamp with time zone: " " CONTEXT:  COPY auth_user, line 55, column
>last_login: " "

I've also tried to modify the fields setting them to NULL but returns the same error.

file.csv is done like that:

"id";"password";"last_login";"is_superuser";"username";"first_name";"last_name";"email";"is_staff";"is_active";"date_joined"

//timestamp fields are last_login and date_joined. //myTable is done right in the same way.

Where am I doing wrong?

I've read that COPY doesn't "understand" NULL fields. Anyone know how to solve the problem?

Note:

»When I've created the database I have not set last_login NOT NULL.

previously field, last_login timestamp with time zone, next field

»I can use only the terminal because I'm working on a VM.

Edit: answered by Nick.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.338372 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO