Changes between Version 1 and Version 2 of PythonMysql


Ignore:
Timestamp:
Jul 13, 2007, 1:15:57 PM (17 years ago)
Author:
Nicolas
Comment:

Wikified the whole page

Legend:

Unmodified
Added
Removed
Modified
  • PythonMysql

    v1 v2  
    1 {{{
    2 Various BOINC tools depend on a Python extension module called "MySQLdb".  You
    3 can get the source here:
     1= MySQLdb =
    42
    5 http://sourceforge.net/projects/mysql-python
     3Various BOINC tools depend on a Python extension module called "MySQLdb". You can get the source on [http://sourceforge.net/projects/mysql-python mysql-python sourceforge project].
    64
    7 WARNING: currently (2003/08/28) BOINC requires version 0.9.2 of
    8 Python-MySQLdb, however this could be backported to 0.9.1 in the future as
    9 many Linux distributions seem to have 0.9.1.
     5WARNING: currently (2003/08/28) BOINC requires version 0.9.2 of Python-MySQLdb, however this could be backported to 0.9.1 in the future as many Linux distributions seem to have 0.9.1.
    106
    11 
    12 INSTALLATION INSTRUCTIONS
    13 =========================
     7== Installation instructions ==
    148
    159Lines beginning with "$" indicate example commands to type in bourne shell.
    1610
    17 Lines beginning with "#" indicate example commands to type with write access
    18 to the install location (i.e. su or sudo)
     11Lines beginning with "#" indicate example commands to type with write access to the install location (i.e. su or sudo)
    1912
    2013Lines beginning with ">>> " indicate example commands to type in Python.
    2114
    22 The `shared module' options build a shared library for the Python-MySQLdb
    23 module that is loaded at Python run-time.  This requires that you have a
    24 shared version of the MySQL client library installed, i.e. libmysqlclient.so.
     15The '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`.
    2516
    26 Debian Linux: shared module
    27 ---------------------------
    28     1. Install
    29        # apt-get install python-mysqldb
    30    
    31     [ 2003/07: if you have multiple Python versions installed you may want to do
    32        # apt-get install python2.2-mysqldb
    33             or
    34        # apt-get install python2.3-mysqldb
    35     ]
     17=== Debian Linux: shared module ===
     18 1. Install
     19  {{{
     20# apt-get install python-mysqldb
     21}}}
     22 If you have multiple Python versions installed you may want to do
     23 {{{
     24 # apt-get install python2.2-mysqldb
     25or
     26 # apt-get install python2.3-mysqldb
     27}}}
    3628
    37 Red Hat Linux: shared module
    38 ----------------------------
    39     1. Download MySQL-python
    40        $ wget http://easynews.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python2-0.9.2-1.i386.rpm
     29=== Red Hat Linux: shared module ===
     30 1. Download MySQL-python
     31 {{{
     32$ wget http://easynews.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python2-0.9.2-1.i386.rpm
     33}}}
     34 1. Install
     35 {{{
     36# rpm -i MySQL-python2-0.9.2-1.i386.rpm
     37}}}
    4138
    42     2. Install
    43        # rpm -i MySQL-python2-0.9.2-1.i386.rpm
     39=== Other Unix/Linux: shared module ===
     40 1. Download MySQL-python
     41 {{{
     42$ wget http://easynews.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-0.9.2.tar.gz
     43}}}
     44 1. Unpack
     45 {{{
     46$ gunzip -c MySQL-python-0.9.2.tar.gz | tar xf -
     47}}}
     48 1. Build
     49 {{{
     50$ cd MySQL-python-0.9.2
     51$ python setup.py build
     52}}}
     53 1. Install
     54 {{{
     55# python setup.py install
     56}}}
    4457
    45 Other Unix/Linux: shared module
    46 -------------------------------
    47     1. Download MySQL-python
    48        $ wget http://easynews.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-0.9.2.tar.gz
     58=== Unix/Linux: compiled statically into Python ===
     59 1. Download MySQL-python
     60 {{{
     61$ wget http://easynews.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-0.9.2.tar.gz
     62}}}
     63 1. Unpack
     64 {{{
     65$ gunzip -c MySQL-python-0.9.2.tar.gz | tar xf -
     66}}}
     67 1. Download Python
     68 {{{
     69$ wget http://python.org/ftp/python/2.3/Python-2.3.tgz   
     70}}}
     71 1. Unpack
     72 {{{
     73$ gunzip -c Python-2.3.tgz | tar xf -
     74}}}
     75 1. Copy MySQL files
     76 {{{
     77$ cp MySQL-python-0.9.2/{*.c,*.h} Python-2.3/Modules/
     78$ cp MySQL-python-0.9.2/_mysql_exceptions.py Python-2.3/Lib/
     79$ cp -r MySQL-python-0.9.2/MySQLdb Python-2.3/Lib/
     80}}}
     81 1. Enter the MySQL module in the Python extension setup file.
     82 {{{
     83$ cd Python-2.3/
     84$ perl -wpi.bak -e "s,^_sre _sre.c,_mysql _mysql.c `mysql_config --cflags` `mysql_config --libs`\n$&," Modules/Setup
     85  (This adds the line '_mysql _msql.c [flags]' to Modules/Setup)
    4986
    50     2. Unpack
    51        $ gunzip -c MySQL-python-0.9.2.tar.gz | tar xf -
     87$ perl -wpi.bak -e 's,^LIBSUBDIRS=\s+,$&MySQLdb ,' Makefile.pre.in
     88  (This adds MySQLdb to the list of libraries to install)
     89}}}
     90 1. Configure python
     91 {{{
     92$ cd Python-2.3/
     93$ ./configure --prefix=/usr/local
     94 or whatever path you want instead of /usr/local]
     95}}}
     96 1. Build
     97 {{{
     98$ make
     99}}}
     100 Troubleshooting:
     101  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.
     102  You may want to check Python and MySQLdb are working before installing by running ./python; see below for instructions.
     103 1. Install
     104 {{{
     105$ cd ../Python-2.3/
     106# make install
     107}}}
    52108
    53     3. Build
    54        $ cd MySQL-python-0.9.2
    55        $ python setup.py build
    56 
    57     4. Install
    58        # python setup.py install
    59 
    60 Unix/Linux: compiled statically into Python
    61 -------------------------------------------
    62     1. Download MySQL-python
    63        $ wget http://easynews.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-0.9.2.tar.gz
    64 
    65     2. Unpack
    66        $ gunzip -c MySQL-python-0.9.2.tar.gz | tar xf -
    67 
    68     3. Download Python
    69        $ wget http://python.org/ftp/python/2.3/Python-2.3.tgz   
    70 
    71     4. Unpack
    72        $ gunzip -c Python-2.3.tgz | tar xf -
    73 
    74     5. Copy MySQL files
    75        $ cp MySQL-python-0.9.2/{*.c,*.h} Python-2.3/Modules/
    76        $ cp MySQL-python-0.9.2/_mysql_exceptions.py Python-2.3/Lib/
    77        $ cp -r MySQL-python-0.9.2/MySQLdb Python-2.3/Lib/
    78 
    79     8. Enter the MySQL module in the Python extension setup file.
    80        $ cd Python-2.3/
    81        $ perl -wpi.bak -e "s,^_sre _sre.c,_mysql _mysql.c `mysql_config --cflags` `mysql_config --libs`\n$&," Modules/Setup
    82            (This adds the line '_mysql _msql.c [flags]' to Modules/Setup)
    83 
    84        $ perl -wpi.bak -e 's,^LIBSUBDIRS=\s+,$&MySQLdb ,' Makefile.pre.in
    85            (This adds MySQLdb to the list of libraries to install)
    86 
    87     7. Configure python
    88        $ cd Python-2.3/
    89        $ ./configure --prefix=/usr/local
    90         [or whatever path you want instead of /usr/local]
    91 
    92     8. Build
    93        $ make
    94 
    95        Troubleshooting:
    96            If you get undefined symbols or other compile errors in
    97            _mysql.c you probably didn't add the correct include
    98            directory for mysql. If you get unresolved symbols or other
    99            link errors involving _mysql.o or libmysql.a you probably
    100            didn't add the correct libraries.
    101 
    102        You may want to check Python and MySQLdb are working before installing
    103        by running ./python; see below for instructions.
    104 
    105     9. Install
    106        $ cd ../Python-2.3/
    107        # make install
    108 
    109 Windows: pre-built binary
    110 -------------------------
    111     There is a built python executable available at the URL listed.
    112 
    113 Does it work?
    114 =============
    115     You can check if your Python and/or MySQLdb was compiled and installed
    116     correctly like this:
    117    
    118     $ python
    119     >>> import MySQLdb
    120     >>> MySQLdb.version_info
    121     >>> MySQLdb.connect(db='databasename', user='username')
     109== Does it work? ==
     110You can check if your Python and/or MySQLdb was compiled and installed correctly like this:
     111{{{
     112$ python
     113>>> import MySQLdb
     114>>> MySQLdb.version_info
     115>>> MySQLdb.connect(db='databasename', user='username')
    122116}}}