Even though I can use sqlite to develop in my portable Django environment (see my previous post: Setting up a portable Django development environment with virtualenvs on Windows to carry on a USB stick), I still wanted to be able to use a real DB engine like PostgreSQL so I looked for a way to make it portable as well.
And unzip the file.
This solution comes from http://www.postgresonline.com/journal/archives/172-Starting-PostgreSQL-in-windows-without-install.html
Just change the first two settings to set the right path.
=> The first time you launch it, you MUST uncomment the line with the initdb command.
Then, you can comment it and run it to normally launch the server.
Below are the information needed to connect to the server.
=> If you read my previous post about getting a portable Django environment, you will just have to unzip the binaries in the development/tools/PostgreSQL folder.
The .bat files already exist.
This is the one recommended by Django for PostgreSQL in the documentation.
Using “pip install psycopg2″ will not work on Windows.
Instead, you must use win-psycopg which is a windows port of the psycopg python-postgresql database interface.
Note that on the portable environment I defined on my previous post, easy install is available via easy_install (with an underscore) and not easy-install (with a hyphen) (This is Windows specific.)
As usual, feel free to leave comment and/or send me your feedback.
1) Download and unzip the PostgreSQL binaries
Go on the PostgreSQL website to download the zip archive of the binaries hosted by EnterpriseDB on this page: http://www.enterprisedb.com/products-services-training/pgbindownloadAnd unzip the file.
2) Make a .bat to launch the server
Let’s create a .bat to launch the PostgreSQL server and set up the main settings like the database name, the user, the port, etc.This solution comes from http://www.postgresonline.com/journal/archives/172-Starting-PostgreSQL-in-windows-without-install.html
Just change the first two settings to set the right path.
Then, you can comment it and run it to normally launch the server.
3) Make a .bat to launch pgAdmin III
Just change the first two settings to set the right path.- Host: localhost
- Port TCP: 5439 (you can change it in the script above)
- Database: postgres
- User: postgres
- Password: (no passwords have been set up, leave it blank)
=> If you read my previous post about getting a portable Django environment, you will just have to unzip the binaries in the development/tools/PostgreSQL folder.
The .bat files already exist.
3) Use PostgreSQL with Django on the portable environment
We need to install psycopg2: a PostgreSQL database adapter for the Python programming language.This is the one recommended by Django for PostgreSQL in the documentation.
Using “pip install psycopg2″ will not work on Windows.
Instead, you must use win-psycopg which is a windows port of the psycopg python-postgresql database interface.
- Go on this page to download it: http://www.stickpeople.com/projects/python/win-psycopg/
- Download the .exe of the right version you need
- Install it via:
Note that on the portable environment I defined on my previous post, easy install is available via easy_install (with an underscore) and not easy-install (with a hyphen) (This is Windows specific.)
As usual, feel free to leave comment and/or send me your feedback.
No hay comentarios:
Publicar un comentario