Loading the Sample Databases
jvl98l opened this issue · 3 comments
In the book, it states "To install the database on PostgreSQL, copy the data.dump file from the Datasets folder in the GitHub repository of the book.......Then, load the data.dump file from a command line using the command:
psql < data.dump"
Can someone please provide clarification on how this is done?? I've had the same issue as someone else when clicking on file that it brings up the code in a separate window. The book did not do a good job at explaining much of anything in terms of downloading software or loading the data.
Had the same issue on Mac
The issue I encountered was due to a later version of OpenSSL I had: v1.1.1.dylib
I needed to point to an earlier version: v1.0.0.dylib
When I executed the psql command psql I got the following error:
"dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/lib/libpq.5.dylib
Reason: image not found
Abort trap: 6"
The resolution I used:
-
brew uninstall --ignore-dependencies openssl brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
-
brew switch openssl
ls /usr/local/cellar/openssl | sed 's/\///g' -
psql -U user -d database < /Users/user/directory/data.dump
Hope this helps
Obviously, it's probably a little late to help out OP, but hopefully this helps other students who are stumped by this as well.
Here is the way I figured it out:
- Open the SQL Shell (psql), that came with the PostgreSQL installation package.
- Connect to the server/database/user that you would like to use. If you are just using the default settings, you can just press enter until it prompts you for the password.
- Type in the password you set for that user and press Enter
- On the command line, change your directory to the location of the data.dump file. Using this command:
dbname=#\cd C:/Users/..../SQL-for-Data-Analytics-master/Datasets (Make sure you pay attention to the direction of the slash marks. If you copy and paste the location from the File Properties in Windows, the slashes will be wrong) - Now that you are in the correct directory, you can use a psql command to load the dump file:
dbname=# \i data.dump - After psql has finished loading the file, I had to exit and restart the psql terminal before my database would recognize the new tables. I don't know if that is 100% necessary, or if a COMMIT statement would do the same thing.
Best of luck!