I'm using PostgresSQL 10 and RPostgreSQL package in R.
I create a new table:
CREATE TABLE people (
id integer NOT NULL,
name character varying,
birthdate date,
deathdate date
);
Then attempt to copy the file :
COPY people (id, name, birthdate, deathdate)
FROM '\people.sql'
ENCODING 'UTF-8';
Then get the following error:
Error in postgresqlExecStatement(conn, statement, ...) : RS-DBI
driver: (could not Retrieve the result : ERROR: invalid input syntax
for integer: "1" CONTEXT: COPY people, line 1, column id: "1"
I did wonder if this was an encoding error, so ran and got:
readr::guess_encoding("\people.sql")
# A tibble: 4 x 2
encoding confidence
<chr> <dbl>
1 UTF-8 1.00
2 windows-1252 0.37
3 windows-1254 0.37
4 windows-1250 0.28
I've tried the other, less probable windows encodings, but this do not work either and throws similar issues with line 1, for instance windows-1252 shows ERROR: invalid input syntax for integer: "1"
The first few lines of the file are:
1 50 Cent 1975-07-06 \N
2 A. Michael Baldwin 1963-04-04 \N
and the last two lines :
8396 Zubaida Sahar \N \N
8397 Zuhair Haddad \N \N
\.
Any idea what could be causing this?
Thank you