postgresql - pgadmin import issue? -
i trying import following csv file imported pgadmin.
csv file:
"id";"email";"password";"permissions";"activated";"activation_code";"activated_at";"last_login";"persist_code";"reset_password_code";"first_name";"last_name";"created_at";"updated_at" "11";"test.teset@gmail.com";"$2y$10$gnfdfvcgqhqzcgkoilukfeskycupzk1akjvk6pdxt1dmmjoocuypi";"";"t";"xy56hncfheacawzuhleyhvvbxxmoamr57ifyehxiud";"";"2014-05-27 08:47:33";"$2y$10$g0lnastma/kewuhndfwleojqeyo9magvvilfijms/kpripadfbwhm";"";"";"";"2014-05-27 07:51:07";"2014-05-27 08:47:33" "5";"test@gmail.com";"$2y$10$dxodoi520pddcmisxcs/ouih.4k/87lexeqrzvul2k/uth2humpny";"";"t";"4k8s1tbgrpfamcnozvep19moqkcapq0la8bhgkf55a";"";"2014-05-21 21:18:06";"$2y$10$cefsnbqizajbo5pfbmdzkuhzpw17fhqh/frwabmljzjvv0a5vkt1o";"";"";"";"2014-05-21 21:17:45";"2014-05-22 19:12:01"
and command using import csv file,
drop table users; create table users ( id serial not null, email character varying(255) not null, password character varying(255) not null, permissions text, activated boolean not null default true, activation_code character varying(255), activated_at timestamp without time zone, last_login timestamp without time zone, persist_code character varying(255), reset_password_code character varying(255), first_name character varying(255), last_name character varying(255), created_at timestamp without time zone, updated_at timestamp without time zone ); copy users (email,password,permissions,activated,activation_code,activated_at,last_login,persist_code,reset_password_code,first_name,last_name,created_at,updated_at) 'd:/test/db_backup/data_csv.csv' csv header delimiter ';' ;
but getting following error, not sure why.
**error: data after last expected column sql state: 22p04**
please let me know issue here?
because have 14 columns of data 13 inside copy statement. specifically, missing id column in copy statment. if data in same order declared in table, there no need put column names in copy table statement.
copy users 'd:/test/db_backup/data_csv.csv' csv header delimiter ';' null '\n';
will work fine in case -- note don't need either.
edit. need explicitly set null value, in, null '\n'. if use "", can error such as: "csv quote character must not appear in null specification". also, can specify header in csv mode, if want use header, , csv, cannot use "" delimiter, , must use explicit null '\n'.
i have updated original answer include , imported sample data, after replacing "" \n.
Comments
Post a Comment