Page 1 of 1

importing *.sql

PostPosted: Tue Feb 26, 2008 8:48 pm
by woznyfrust
Hi,
I made a backup of my PT3 Database with a tool and a dump.sql came out. How can I import these extra hands into an existing PT3 database?

woznyfrust

Re: importing *.sql

PostPosted: Wed Feb 27, 2008 2:16 am
by APerfect10
You will need to do it via the command line using psql which is located under the bin directory below PostgreSQL.

[codeum4]psql dbname < infile[/codeum4]

dbname = New database name
infile = the directory/filename of your dump.sql file. (I recommend moving the dump.sql to your bin directory so that you can simply list the filename)

Best regards,

Derek

Re: importing *.sql

PostPosted: Thu Feb 28, 2008 8:06 am
by woznyfrust
Hi APerfect10,
thank you for your answer. The import works fine and I can watch the hands afterwards. But when I now try to import additional hands after that I get a duplicate errors for every new file, even if they are not yet in.
Is there a way to solve this?

woznyfrust

Re: importing *.sql

PostPosted: Thu Feb 28, 2008 1:15 pm
by APerfect10
Are you sure these are new files with new hands? The only reason that it should give the duplicate hand warning message is if the game number is already in the database.

Best regards,

Derek

Re: importing *.sql

PostPosted: Thu Feb 28, 2008 1:33 pm
by woznyfrust
My database is called "PT3_PS1", the dump1.sql is in the /bin folder.
I did "psql PT3_PS1 < dump1.sql" at the Command Prompt.

a lot of this comes up:
ERROR: duplicate key value violates unique constraint "tourney_holdem_hand_histories_primary_key"

and a lot of this comes up:
"INSERT 0 1"

Regards,
woznyfrust

Re: importing *.sql

PostPosted: Thu Feb 28, 2008 1:45 pm
by APerfect10
So these messages are when you do the psql restore or when you are importing new hands?

If it is during the restore, is "PT3_PS1" an existing database name? You should be restoring to a brand new database, you do not restore into an existing database.

Best regards,

Derek

Re: importing *.sql

PostPosted: Thu Feb 28, 2008 7:04 pm
by woznyfrust
Hi Derek,
i would like to add the dump1.sql into an existing database.

Regards,
woznyfrust

Re: importing *.sql

PostPosted: Thu Feb 28, 2008 7:40 pm
by APerfect10
Sorry, re-reading your OP you do say 'existing'. The word dump took me in another direction. A dump/restore is meant to backup an entire database and restore the entire database. You can't restore into an existing database (to my knowledge) using a dump file.

If you wanted to retrieve data that could be inserted into an existing database you would need to use the [url=http://www.postgresql.org/docs/8.3/interactive/sql-copy.htmllw3]COPY command[/urllw3]. You would COPY from a table to a file then COPY from the file into the new database's table.

Best regards,

Derek