No title
hi all,
I am using postgres 9.4 on windows 7.
i want import that backup sql file into postgres schema.
i googled i got copy, but when i ran in windows
COPY actor FROM 'c:\users\venu\downloads\sakila-data.sql';
ERROR: invalid input syntax for integer: ""
CONTEXT: COPY actor, line 1, column actor_id: ""
********** Error **********
the backupdata format
COPY actor (actor_id, first_name, last_name, last_update) FROM stdin;
1 PENELOPE GUINESS 2006-02-15 09:34:33
2 NICK WAHLBERG 2006-02-15 09:34:33
3 ED CHASE 2006-02-15 09:34:33
4 JENNIFER DAVIS 2006-02-15 09:34:33
how to import to table from file in postgres
any help..?
On 03/03/2015 04:39 AM, Ramesh T wrote:
hi all,
I am using postgres 9.4 on windows 7.i want import that backup sql file into postgres schema.
i googled i got copy, but when i ran in windowsCOPY actor FROM 'c:\users\venu\downloads\sakila-data.sql';
ERROR: invalid input syntax for integer: ""
The problem is above, you can not have an empty string in a integer
field. That is a MySQLism for NULL. There is a version of the Sakila
data files rewritten for Postgres, called Pagila. Unfortunately it is on
PgFoundry (http://pgfoundry.org/projects/dbsamples/) and that site seems
to be dead. So you have couple of options, sanitize the data files
using some text tools to clean out the empty strings or make the table
field a varchar and clean the data there and then change back to integer.
CONTEXT: COPY actor, line 1, column actor_id: ""
********** Error **********the backupdata format
COPY actor (actor_id, first_name, last_name, last_update) FROM stdin;
1 PENELOPE GUINESS 2006-02-15 09:34:33
2 NICK WAHLBERG 2006-02-15 09:34:33
3 ED CHASE 2006-02-15 09:34:33
4 JENNIFER DAVIS 2006-02-15 09:34:33how to import to table from file in postgres
any help..?
--
Adrian Klaver
adrian.klaver@aklaver.com
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Hi Ramesh:
On Tue, Mar 3, 2015 at 1:39 PM, Ramesh T <rameshparnanditech@gmail.com>
wrote:
i want import that backup sql file into postgres schema.
i googled i got copy, but when i ran in windows
If the backup is an SQL file you just ran it with psql. If it is a DATA
file, you copy it:
COPY actor FROM 'c:\users\venu\downloads\sakila-data.sql';
You are copying a .sql file, that smells fishy.
ERROR: invalid input syntax for integer: ""
CONTEXT: COPY actor, line 1, column actor_id: ""
This may be caused by
the backupdata format
COPY actor (actor_id, first_name, last_name, last_update) FROM stdin;
1 PENELOPE GUINESS 2006-02-15 09:34:33
2 NICK WAHLBERG 2006-02-15 09:34:33
3 ED CHASE 2006-02-15 09:34:33
4 JENNIFER DAVIS 2006-02-15 09:34:33
If your file includes the COPY ... from STDIN then it is definitely an SQL
file, it is self contained, the copy from STDIN instructs psql to get the
data lines following it until EOF or a \. is found. It is similar to which
pg_dump will produce.
A data file would be just the data lines. PSQL would not understand it,
but "copy from xxxx.dat" would be fine.
What is exactly in your data file ? If it includes copy from stdin, then
'psql -f data.sql' would do the trick ( add approiate database names,
host, password, as needed, just the same you would use in an standard psql
command, remember db name goes last ).
Regards
Francisco Olarte.