[Pythonmac-SIG] Summary of installing the pyPgSQL postgresql driver
on Mac Os X
Marlon A. Griffith
marlong at rogers.com
Tue Dec 23 19:31:31 EST 2003
Goal: to make it easier for a newbie to MacPython and Postgresql to
communicate between Python and Postgresql on Mac Os X using the
pyPgSQL driver. I found that the information is available but not
compiled into one area. Hopefully, this will provide that area.
1) for installing Postgresql see "Postgresql on Mac OS X" at mother
2) for installing MacPython see the MacPython site,
3) for installing pyPgSQL see the readMe at http://pypgsql.sourceforge.net/
4) Russell E. Owen for his Mon Dec 16, 2002 and Mon, 15 Dec 2003
emails on this list
5) the MacPython documentation and faq will give you an idea of where
code is installed.
Acknowledgements: thanks Russell.
- postgresql 7.3
- MacPython 2.3, the July 30th 2003 release.
- install Postgresql as in reference 1
- install MacPython as in refernce 2
- begin installing pyPgSQL as in reference 3
- unfortunately, it will not compile correctly. Quoting Russell's
solution in the Dec 16, 2002 email:
One: the build process first failed with a complaint about a bad
library table of contents, and suggested running ranlib. The following
fixed that (knowing nothing about ranlib but finding the suggestion via
sudo ranlib libpq.a
At this point the build and installation went fine (though I started
with a freshly unpacked source directory, just to be on the safe side):
python setup.py build
sudo python setup.py install
This worked great.
- to further test the compiled module, boot up the pythonIDE program and type,
from pyPgSQL import pgSQL
python will now inspect the module for you.
to get detailed help on methods and parameters for pgSQL.
- when you are done playing, quit the pythonIDE program.
- start Postgresql again if necessary, reference 1
- create the pypgsql database as in reference 3
- use Russell's Dec. 15 2003 suggestion to "put /usr/local/bin before
/usr/bin in your PATH" variable since this will put the command line
MacPython before Apple's python in your unix system search path. Type
the following command,
setenv PATH "/usr/local/bin:/Library/Tcl/bin:"$PATH
- unfortunately, running the test script (reference 3):
gave a password error when I ran the script as the Posgresql admin user.
- the missing component was authentication permissions for my main
user in the Postgresql pg_hba.conf file. Add this line to your
#TYPE DATABASE USER IP-ADDRESS
local pypgsql macUserName
local refers to the localhost ip-address on your machine,
macUserName is your login account that you do work with or will
run MacPython from, and
trust is the authentication method. It means give this user full
access without prompting for a password. Note that you would change
this method to a password in a production environment. See
- start Posgresql using the pypgsql database (reference 1):
psql pypgsql postgres
where "postgres" is my Posgresql admin user.
- create a user group for the database (reference 1):
pypgsql=# create group pygsql;
where "pypgsql=#" is the Posgresql prompt string for this database.
In other words, you don't type that string.
- create your testuser with no password for the database using the
same user name that you added to the pg_hba.conf file (see reference
pypgsql=# create user macUserName;
- add your testuser to the group,
pypgsql=# alter group pypgsql add user macUserName;
- you can exit Posgresql if you want
- run the test script as above.
- I got,
Ran 66 tests in 4.405s
You are now up and running. Happy Postgresql pythoning.
Make it a great day!
"We move ahead by going deeper." Jennifer James (1943- ) American Writer
"Don't let your schooling interfere with your education." Mark Twain
"Do not parrot the words of famous people. Learn the meaning of what they
say and repeat it in your own words." Mark Twain (not an exact quote).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pythonmac-SIG