importing *.sql

PostgreSQL is the database server used to store information. Do you have a question or are you having problem with PostgreSQL? If so, post them here.

Moderator: Moderators

importing *.sql

Postby woznyfrust » Tue Feb 26, 2008 8:48 pm

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
woznyfrust
 
Posts: 8
Joined: Sun Feb 24, 2008 1:23 pm

Re: importing *.sql

Postby APerfect10 » Wed Feb 27, 2008 2:16 am

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
APerfect10
Site Admin
 
Posts: 4465
Joined: Sat Dec 08, 2007 6:03 pm

Re: importing *.sql

Postby woznyfrust » Thu Feb 28, 2008 8:06 am

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
woznyfrust
 
Posts: 8
Joined: Sun Feb 24, 2008 1:23 pm

Re: importing *.sql

Postby APerfect10 » Thu Feb 28, 2008 1:15 pm

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
APerfect10
Site Admin
 
Posts: 4465
Joined: Sat Dec 08, 2007 6:03 pm

Re: importing *.sql

Postby woznyfrust » Thu Feb 28, 2008 1:33 pm

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
woznyfrust
 
Posts: 8
Joined: Sun Feb 24, 2008 1:23 pm

Re: importing *.sql

Postby APerfect10 » Thu Feb 28, 2008 1:45 pm

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
APerfect10
Site Admin
 
Posts: 4465
Joined: Sat Dec 08, 2007 6:03 pm

Re: importing *.sql

Postby woznyfrust » Thu Feb 28, 2008 7:04 pm

Hi Derek,
i would like to add the dump1.sql into an existing database.

Regards,
woznyfrust
woznyfrust
 
Posts: 8
Joined: Sun Feb 24, 2008 1:23 pm

Re: importing *.sql

Postby APerfect10 » Thu Feb 28, 2008 7:40 pm

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
APerfect10
Site Admin
 
Posts: 4465
Joined: Sat Dec 08, 2007 6:03 pm


Return to PostgreSQL [Read Only]

Who is online

Users browsing this forum: No registered users and 10 guests

cron