Thread: Why don't dumped files parse in pgAdmin3 query editor?

Why don't dumped files parse in pgAdmin3 query editor?

From
dlivesay@covad.net
Date:
Here's something I've always wondered. When you dump a database, the dumped file
looks like ordinary SQL, but if I load it into a query editor window and try to
execute it, I always get syntax errors. The specific errors vary, but it always
makes it impossible to reload the data that way.

In the past I've just used psql -f [file] [schema] to reload them, but I'm
trying to do this on Windows, and I can't seem to get anything to work from the
command shell, so I'm really stuck.

Re: Why don't dumped files parse in pgAdmin3 query editor?

From
Raymond O'Donnell
Date:
On 05/03/2007 15:28, dlivesay@covad.net wrote:

> Here's something I've always wondered. When you dump a database, the dumped file
> looks like ordinary SQL, but if I load it into a query editor window and try to
> execute it, I always get syntax errors. The specific errors vary, but it always
> makes it impossible to reload the data that way.

That's because theses files contain psql-specific "backslash" commands
as well as ordinary SQL - if you look at what the errors tell you,
you'll probably see that they come from lines containing such commands.
As I understand it, the plain-text output of pg_dump is intended to be
restored via psql.

Ray.


---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
---------------------------------------------------------------

Re: Why don't dumped files parse in pgAdmin3 query editor?

From
Raymond O'Donnell
Date:
On 05/03/2007 15:28, dlivesay@covad.net wrote:

> In the past I've just used psql -f [file] [schema] to reload them, but I'm
> trying to do this on Windows, and I can't seem to get anything to work from the
> command shell, so I'm really stuck.

What happens when you try to do it from the command shell? Show us your
commands and the output.

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
---------------------------------------------------------------

Re: Why don't dumped files parse in pgAdmin3 query editor?

From
Magnus Hagander
Date:
On Mon, Mar 05, 2007 at 10:28:04AM -0500, dlivesay@covad.net wrote:
> Here's something I've always wondered. When you dump a database, the dumped file
> looks like ordinary SQL, but if I load it into a query editor window and try to
> execute it, I always get syntax errors. The specific errors vary, but it always
> makes it impossible to reload the data that way.
>
> In the past I've just used psql -f [file] [schema] to reload them, but I'm
> trying to do this on Windows, and I can't seem to get anything to work from the
> command shell, so I'm really stuck.

It should work perfectly fine to restore it using psql -f on Windows as
well, I'd recommend that you look into why that's not working and try to
fix that instead.

//Magnus

Re: Why don't dumped files parse in pgAdmin3 query editor?

From
"Joris Dobbelsteen"
Date:
>-----Original Message-----
>From: pgsql-general-owner@postgresql.org
>[mailto:pgsql-general-owner@postgresql.org] On Behalf Of
>dlivesay@covad.net
>Sent: maandag 5 maart 2007 16:28
>To: pgsql-general@postgresql.org
>Subject: [GENERAL] Why don't dumped files parse in pgAdmin3
>query editor?
>
>Here's something I've always wondered. When you dump a
>database, the dumped file looks like ordinary SQL, but if I
>load it into a query editor window and try to execute it, I
>always get syntax errors. The specific errors vary, but it
>always makes it impossible to reload the data that way.
>
>In the past I've just used psql -f [file] [schema] to reload
>them, but I'm trying to do this on Windows, and I can't seem
>to get anything to work from the command shell, so I'm really stuck.

It seems it has some strange syntax that might be psql-specific, perhaps
its even for linux only.

However, it might make some difference if you dump with "Use insert
statements" instead of the normal copy from stdin. This seemed to work
for me last time. Your mileage may vary.

- Joris

Re: Why don't dumped files parse in pgAdmin3 query editor?

From
dlivesay@covad.net
Date:
Quoting Magnus Hagander <magnus@hagander.net>:

> It should work perfectly fine to restore it using psql -f on Windows as
> well, I'd recommend that you look into why that's not working and try to
> fix that instead.

The main problem I'm having is that any command I try to use with psql, even
psql /?, causes it to prompt me for a password, and it tells me my password is
wrong no matter what username/passsword combination I try.

Beyond that, I really don't know what the correct syntax to use in the Windows
command shell is. Would it be "psql -f" or "psql /f"?

Re: Why don't dumped files parse in pgAdmin3 query editor?

From
Raymond O'Donnell
Date:
On 05/03/2007 15:58, dlivesay@covad.net wrote:

> The main problem I'm having is that any command I try to use with
> psql, even psql /?, causes it to prompt me for a password, and it
> tells me my password is wrong no matter what username/passsword
> combination I try.

Are you using the -U option to connect as a specific user? If you don't,
psql tries to connect as the currently logged-in user.

> Beyond that, I really don't know what the correct syntax to use in
> the Windows command shell is. Would it be "psql -f" or "psql /f"?

Try "psql --help":

C:\Documents and Settings\rod>psql --help
This is psql 8.2.3, the PostgreSQL interactive terminal.

Usage:
   psql [OPTIONS]... [DBNAME [USERNAME]]

General options:
   -d DBNAME       specify database name to connect to (default: "rod")
   -c COMMAND      run only single command (SQL or internal) and exit
   -f FILENAME     execute commands from file, then exit
   -1 ("one")      execute command file as a single transaction
   -l              list available databases, then exit
   -v NAME=VALUE   set psql variable NAME to VALUE
   -X              do not read startup file (~/.psqlrc)
   --help          show this help, then exit
   --version       output version information, then exit

Input and output options:
   -a              echo all input from script
   -e              echo commands sent to server
   -E              display queries that internal commands generate
   -q              run quietly (no messages, only query output)
   -o FILENAME     send query results to file (or |pipe)
   -n              disable enhanced command line editing (readline)
   -s              single-step mode (confirm each query)
   -S              single-line mode (end of line terminates SQL command)
   -L FILENAME     send session log to file

Output format options:
   -A              unaligned table output mode (-P format=unaligned)
   -H              HTML table output mode (-P format=html)
   -t              print rows only (-P tuples_only)
   -T TEXT         set HTML table tag attributes (width, border) (-P
tableattr=)
   -x              turn on expanded table output (-P expanded)
   -P VAR[=ARG]    set printing option VAR to ARG (see \pset command)
   -F STRING       set field separator (default: "|") (-P fieldsep=)
   -R STRING       set record separator (default: newline) (-P recordsep=)

Connection options:
   -h HOSTNAME     database server host or socket directory (default:
"local sock
et")
   -p PORT         database server port (default: "5432")
   -U NAME         database user name (default: "rod")
   -W              prompt for password (should happen automatically)

For more information, type "\?" (for internal commands) or "\help"
(for SQL commands) from within psql, or consult the psql section in
the PostgreSQL documentation.

Report bugs to <pgsql-bugs@postgresql.org>.

HTH,

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
---------------------------------------------------------------

Re: Why don't dumped files parse in pgAdmin3 query editor?

From
Magnus Hagander
Date:
On Mon, Mar 05, 2007 at 10:58:32AM -0500, dlivesay@covad.net wrote:
> Quoting Magnus Hagander <magnus@hagander.net>:
>
> >It should work perfectly fine to restore it using psql -f on Windows as
> >well, I'd recommend that you look into why that's not working and try to
> >fix that instead.
>
> The main problem I'm having is that any command I try to use with psql, even
> psql /?, causes it to prompt me for a password, and it tells me my password
> is
> wrong no matter what username/passsword combination I try.
>
> Beyond that, I really don't know what the correct syntax to use in the
> Windows
> command shell is. Would it be "psql -f" or "psql /f"?

it's psql -f. So you should be using psql -? to get the help.

//Magnus