Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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;
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;
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?



pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group