boinc/doc/install_python_mysqldb.txt

118 lines
3.8 KiB
Plaintext

;; $Id$
To run the test scripts in test/ you need a Python extension module called
"MySQLdb". You can get the source here:
http://sourceforge.net/projects/mysql-python
INSTALLATION INSTRUCTIONS
=========================
Lines beginning with "$" indicate example commands to type in bourne shell.
Lines beginning with "#" indicate example commands to type with write access
to the install location (i.e. su or sudo)
Lines beginning with ">>> " indicate example commands to type in Python.
The `shared module' options build a shared library for the Python-MySQLdb
module that is loaded at Python run-time. This requires that you have a
shared version of the MySQL client library installed, i.e. libmysqlclient.so.
Debian Linux: shared module
---------------------------
1. Install
# apt-get install python-mysqldb
[ 2003/07: if you have multiple Python versions installed you may want to do
# apt-get install python2.2-mysqldb
or
# apt-get install python2.3-mysqldb
]
Red Hat Linux: shared module
----------------------------
1. Download MySQL-python
$ wget http://easynews.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-0.9.2-1.i386.rpm
2. Install
# rpm -i MySQL-python-0.9.2-1.i386.rpm
Other Unix/Linux: shared module
-------------------------------
1. Download MySQL-python
$ wget http://easynews.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-0.9.2.tar.gz
2. Unpack
$ gunzip -c MySQL-python-0.9.2.tar.gz | tar xf -
3. Build
$ cd MySQL-python-0.9.2
$ python setup.py build
4. Install
# python setup.py install
Unix/Linux: compiled statically into Python
-------------------------------------------
1. Download MySQL-python
$ wget http://easynews.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-0.9.2.tar.gz
2. Unpack
$ gunzip -c MySQL-python-0.9.2.tar.gz | tar xf -
3. Download Python
$ wget http://python.org/ftp/python/2.3/Python-2.3.tgz
4. Unpack
$ gunzip -c Python-2.3.tgz | tar xf -
5. Copy MySQL files
$ cp MySQL-python-0.9.2/{*.c,*.h} Python-2.3/Modules/
$ cp MySQL-python-0.9.2/_mysql_exceptions.py Python-2.3/Lib/
$ cp -r MySQL-python-0.9.2/MySQLdb Python-2.3/Lib/
8. Enter the MySQL module in the Python extension setup file.
$ cd Python-2.3/
$ perl -wpi.bak -e "s,^_sre _sre.c,_mysql _mysql.c `mysql_config --cflags` `mysql_config --libs`\n$&," Modules/Setup
(This adds the line '_mysql _msql.c [flags]' to Modules/Setup)
$ perl -wpi.bak -e 's,^LIBSUBDIRS=\s+,$&MySQLdb ,' Makefile.pre.in
(This adds MySQLdb to the list of libraries to install)
7. Configure python
$ cd Python-2.3/
$ ./configure --prefix=/usr/local
[or whatever path you want instead of /usr/local]
8. Build
$ make
Troubleshooting:
If you get undefined symbols or other compile errors in
_mysql.c you probably didn't add the correct include
directory for mysql. If you get unresolved symbols or other
link errors involving _mysql.o or libmysql.a you probably
didn't add the correct libraries.
You may want to check Python and MySQLdb are working before installing
by running ./python; see below for instructions.
9. Install
$ cd ../Python-2.3/
# make install
Windows: pre-built binary
-------------------------
There is a built python executable available at the URL listed.
Does it work?
=============
You can check if your Python and/or MySQLdb was compiled and installed
correctly like this:
$ python
>>> import MySQLdb
>>> MySQLdb.version_info
>>> MySQLdb.connect(db='databasename', user='username')