- Download and run the Postgres Windows installer http://www.postgresql.org/download/windows/
- Initally the only user will be
postgres
. Edit thepg_hba.conf
file (probably in C:\Program Files (x86)\PostgreSQL\8.4\data) to addtrust
to all themethods
- Additionally, add
local all all trust
to the top row to allow localhost access. - Use
createuser
(in C:\Program Files (x86)\PostgreSQL\8.4\bin) to create a new database (super)user- See: http://www.postgresql.org/docs/8.1/static/app-createuser.html
- Protip: add C:\Program Files (x86)\PostgreSQL\8.4\bin\ to your user's PATH
- Use
createdb
to create a new database
Test you can access the new database via PgAdminIII.
- Run
pg_dump
with appropriate options on production server (something likepg_dump --create --host=HOST --port=PORT --username=USERNAME mydatabase > django_db_backup.sql
)--create
includes appropriate CREATE statements to recreate the database from the file.
- Copy file to local machine (using FTP or something like
pscp
. For examplepscp acadmin@spider:path/to/file.sql C:\path\to\local\copy.sql
) - On local machine use copied file as input to
psql
similar to this:psql -U USERNAME --file django_db_backup.sql
As written, the above will require the same pre-created database name and username to exist locally as on the production server.
Best: pip install
in a virtualenv
- Create a virtualnev to build your Django environment in http://www.tylerbutler.com/2012/05/how-to-install-python-pip-and-virtualenv-on-windows-with-powershell/
- Switch to the created virtualenv and
pip install
the appropriatepsycopg2
for your python version number and 32/64bit level from here: https://github.com/nwcell/psycopg2-windows
Alternative: Download a precompiled Windows installer
- Download and run the appropriate release file from this page: http://www.stickpeople.com/projects/python/win-psycopg/