Skip to content

Detailed Windows PostgreSQL installation

ochawkeye edited this page Sep 24, 2014 · 13 revisions

Step-by-step installation of PostgreSQL

Windows 8 (64-bit) OS

  1. Download PostgreSQL-9.3.0-1-windows.exe
  2. Try to run downloaded file but halted by too smart for its own good OS
3. Click `More info` and `Run anyway` 4. Setup wizard begins, click `Next` 5. Specify installation directory, click `Next` 6. Specify data directory, click `Next` 7. Assign password for superuser named `postgres`, click `Next` 8. Leave port number with default `5432`, click `Next` 9. Leave `Advanced Options` locale with `[Default locale]`, click `Next` 10. Wizard complete, ready to install, click `Next` 11. Wait while installation completes 12. Finished installing, click `Finish` 13. A new wizard opens up - Stack Builder 3.1.1; This wizard we are going to ignore. Click `Cancel` -> `Yes` 14. Open Command Prompt and navigate to the install location selected in step 5. above 15. `createuser.exe -U postgres -E -P nfldb` Using superuser `postgres`, create a new user named `nfldb`. Assign a password for user `nfldb`, enter it again to confirm, and finally enter the password for account `postgres` that you assigned in step 7. above 16. `createdb.exe -U postgres -O nfldb nfldb` Using superuser `postgres`, create a new database named `nfldb`. Make the owner of this database user `nfldb` 17. `psql.exe -U postgres -c "CREATE EXTENSION fuzzystrmatch;" nfldb` Enable fuzzy string matching 18. `psql.exe -U nfldb nfldb` Using user `nfldb`, log into database `nfldb` `\q` to exit 19. Download [nfldb.sql.zip](http://burntsushi.net/stuff/nfldb/nfldb.sql.zip) 20. Extract downloaded zip file 21. `psql.exe -U nfldb nfldb < x:\path\to\extracted\nfldb.sql\nfldb.sql` Using user `nfldb`, import the downloaded sql database into database `nfldb` _Please note that you are importing the `nfldb.sql` *file* that you unzipped and not the `nfldb.sql` *folder* that the file resides in. If you are seeing `Access is denied.` it is likely that you are trying to incorrectly import the folder_ 22. Wait for database to import - took me about 6 minutes on older PC 23. Create a copy of the sample config file found in `x:\Python27\share\nfldb` Rename this copy `config.ini` Edit two values in this config file: the timezone & the password for user `nfldb`; save and close the file 24. Create and save a file called `top-ten-qbs.py` ```python import nfldb

db = nfldb.connect() q = nfldb.Query(db)

q.game(season_year=2012, season_type='Regular') for pp in q.sort('passing_yds').limit(10).as_aggregate(): print pp.player, pp.passing_yds

<img src="https://cloud.githubusercontent.com/assets/2996205/3774695/3e3cf8de-1931-11e4-9c41-6b793e52a622.png" width="400px"/>  
25.  From a command prompt, run `python top-ten-qbs.py`  
<img src="https://cloud.githubusercontent.com/assets/2996205/3774699/6cdd4ebe-1931-11e4-8c16-4472589f55bf.png" width="400px"/>  
26.  Finally, run the `nfldb-update` script found in the `Python\Scripts` folder  
<img src="https://cloud.githubusercontent.com/assets/2996205/3774710/e0f2a312-1931-11e4-96b9-ca531a999cbb.png" width="400px"/>  
27.  Congratulations - no one in the world has a more up-to-date `nfldb` database than you.  Time to celebrate with a beer.