Importing Mangled SQL File via psql

From: APseudoUtopia <apseudoutopia(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Importing Mangled SQL File via psql
Date: 2009-08-25 21:20:27
Message-ID: 27ade5280908251420g6f704d3xddc7a96d4266300b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)main_db => BEGIN;
BEGIN
Time: 0.243 ms
db_user(at)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(at)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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Napier 2009-08-25 22:25:35 Posting error
Previous Message Tom Lane 2009-08-25 21:03:42 Re: PL/pgSQL infinite loop in "UPDATE/INSERT" example