ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I have been trying to get a connection between Python and a back-end database
: something that I expected to be a trivial exercise. Unfortunately, I seem
to be getting nowhere and could really do with some help.
My environment : Python 2.3 (#2, Aug 31 2003, 17:27:29)
[GCC 3.3.1 (Mandrake Linux 9.2 3.3.1-1mdk)] on linux2
I don't think I have anything compiled from source or in other package formats
relevant to this.
I have tried several versions of the MySQLdb module downloaded from
sourceforge.net/projects/mysql-python. The MySQL-python2-0.9.2-1 rpm got me
closest. I managed to get it installed (though had to ignore one dependency
where I had a newer version of the file it was depending on - always a bad
sign) and get the following message when importing the module
>>> import MySQLdb
Python C API version mismatch for module _mysql: This Python has API version
1012, module _mysql has version 1011.
Other source versions, including the latest test version, fail to compile with
a host of errors.
I thought I would go for PostgreSQL next because the python module ships with
Mandrake. What could go wrong? The module (pg or _pg) loads up fine. I
still can't connect to the datbase though (I created a database called
>>> import _pg
>>> db = _pg.connect('web','localhost')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
_pg.error: could not connect to server: Connection refused
Is the server running on host localhost and accepting
TCP/IP connections on port 5432?
I checked and the database is running and is listening on port 5432.
Next I spotted something in the PostgreSQL manual, that I need to run the
createlang command first. I tried this but no luck :
-bash-2.05b$ createlang plpython web
ERROR: stat failed on file '$libdir/plpython': No such file or directory
createlang: language installation failed
-bash-2.05b$ createlang plpythonu web
createlang: unsupported language "plpythonu"
Supported languages are plpgsql, pltcl, pltclu, plperl, plperlu, and plpython.
I've hunted around and I can't find a plpython file anywhere on my PC so it
isn't installed. However, I also can't see any rpm than I'm missing.
I posted this query to the tutor@python mailing list a week or so ago but unfortunately didn't get any good solutions