Pil Kwon
Pil Kwon

Reputation: 173

copy (pg_dump) .sql file to postgresql using Cygwin

I have downloaded YELP's sql file and tried to import the sql to my local Postgresql.

I am running postgres on Windows 10 and using Cygwin to execute command that I have found on Google. (it took me forever to use Cygwin instead of windows psql shell)

anyhow, Yelp gives data schema in sql and also data in sql. You may find them a link attached below https://www.yelp.com/dataset/download

so, basically what I thought was creating an empty table with YELP's schema the, copy all YELP's data into that table.

pg_dump -h localhost -p 5433 -U postgres -s mydb < D:/YELP/yelp_schema.sql
pg_dump -h localhost -p 5433 -U postgres -d mydb < D:/YELP/yelp_sql-2.tar

and I am checking my database transaction and it doesn't change nothing and i do not see the table.

this is what i see on Cygwin terminal enter image description here

and nothing on my postgresql database

Please let me know what I have missed.

Thanks a lot

Upvotes: 0

Views: 383

Answers (1)

Vao Tsun
Vao Tsun

Reputation: 51519

your link asks for email to download. I would suspect yelp to be not transparent for it. So I did not check if they have any advise on their data sets... Anyway you use pg_dump to dump the data. to import the resulting file use psql for plain sql files and pg_restore for custom format ones...

Eg:

psql -h localhost -p 5433 -U postgres -f D:/YELP/yelp_schema.sql
pg_restore -h localhost -p 5433 -U postgres -s worldmap -Ft D:/YELP/yelp_schema.sql

https://www.postgresql.org/docs/current/static/app-pgdump.html

pg_dump — extract a PostgreSQL database into a script file or other archive file

Upvotes: 1

Related Questions