Importing Mangled SQL File via psql - Mailing list pgsql-general

From APseudoUtopia
Subject Importing Mangled SQL File via psql
Date
Msg-id 27ade5280908251420g6f704d3xddc7a96d4266300b@mail.gmail.com
Whole thread Raw
Responses Re: Importing Mangled SQL File via psql
List pgsql-general
Hey list,

I have a dump of a table from a mysql database. I spent the last two
days running search-and-replace regexes and other such formatting
changes in order to get it loadable into PostgreSQL. I finally got to
what seemed like the end of the process, when this happened as I tried
to load it:

db_user@main_db => BEGIN;
BEGIN
Time: 0.243 ms
db_user@main_db *=> \i data.sql
INSERT 0 431
Time: 679.312 ms
INSERT 0 323
Time: 193.857 ms
Query buffer reset (cleared).
psql:data.sql:3: invalid command \n
db_user@main_db *=> ROLLBACK;
ROLLBACK
Time: 0.458 ms

The file does contain quite a bit of \r\n's in them for newlines
inside VARCHAR and TEXT columns, but I thought they would be converted
into actual newlines as I import it, not the actual character strings
"\n" and "\r". I know that \r is the psql command to clear the query
buffer, which is why that message is showing up in the above log. Does
anyone recommend anything to solve this problem? Should I just replace
\r\n with a space or an actual line break in the sql file itself?

Thanks.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: PL/pgSQL infinite loop in "UPDATE/INSERT" example
Next
From: Rob Napier
Date:
Subject: Posting error