Dumping DB containing json

From: Michael Kovacs <kovacs(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Dumping DB containing json
Date: 2012-01-20 00:21:44
Message-ID: CAPp5r6KOObLWP+SvE5T10A5XX19CmkNf3izibM58Dc405rEd1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi there,

I'm currently stuck on a problem with a db dump from pg_dump that contains
a database with text columns containing json. I'm wondering if there's
something I need to do to properly dump the data that I'm not doing or to
restore.

This is how I'm doing each:

pg_dump -U postgres mydb -f myfile.sql

and to restore:

psql -U postgres mydb -f myfile.sql

I get tons of errors about the nulls in the data along with the following
syntax errors:

psql:rm_prod-1-19-2012.sql:148863: invalid command \N
psql:rm_prod-1-19-2012.sql:148864: invalid command \N
psql:rm_prod-1-19-2012.sql:148865: invalid command \N
psql:rm_prod-1-19-2012.sql:148866: invalid command \N
psql:rm_prod-1-19-2012.sql:148867: invalid command \N
psql:rm_prod-1-19-2012.sql:148868: invalid command \
psql:rm_prod-1-19-2012.sql:148870: invalid command \N
psql:rm_prod-1-19-2012.sql:148871: invalid command \N
psql:rm_prod-1-19-2012.sql:148877: invalid command \N
psql:rm_prod-1-19-2012.sql:148879: invalid command \N
psql:rm_prod-1-19-2012.sql:148882: ERROR: syntax error at or near "",""
LINE 1: ","text":"RT @GSElevator: #1: Congress is allowed to trade o...
^
psql:rm_prod-1-19-2012.sql:148882: ERROR: syntax error at or near "a"
LINE 1: a href=&quot;
^
psql:rm_prod-1-19-2012.sql:148882: ERROR: syntax error at or near "http"
LINE 1: http://blackberry.com/twitter&quot;
^
psql:rm_prod-1-19-2012.sql:148882: ERROR: syntax error at or near "rel"
LINE 1: rel=&quot;
^
psql:rm_prod-1-19-2012.sql:148882: ERROR: syntax error at or near
"nofollow"
LINE 1: nofollow&quot;
^
psql:rm_prod-1-19-2012.sql:148882: ERROR: syntax error at or near "&"
LINE 1: &gt;
^
psql:rm_prod-1-19-2012.sql:148882: invalid command \
psql:rm_prod-1-19-2012.sql:148892: invalid command \N

Any guidance on what I'm doing wrong would be appreciated.

Thanks,
-Michael

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2012-01-20 05:19:34 Re: Dumping DB containing json
Previous Message Tom Browder 2012-01-17 18:08:17 Re: Database Modeling Language