mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-15 19:31:54 +08:00
Convert to restructured text.
This commit is contained in:
251
MySQLdb/README
251
MySQLdb/README
@ -1,18 +1,13 @@
|
|||||||
Warning:
|
====================
|
||||||
|
MySQLdb Installation
|
||||||
If you fail to read all of this document and ask questions that are
|
====================
|
||||||
already answered, I reserve the right to verbally abuse you.
|
|
||||||
|
|
||||||
|
|
||||||
Binary Packages:
|
|
||||||
|
|
||||||
I don't plan to make binary packages any more. However, if someone
|
Prerequisites
|
||||||
contributes one, I will make it available.
|
-------------
|
||||||
|
|
||||||
|
+ Python 2.3.4 or higher
|
||||||
Prerequisites:
|
|
||||||
|
|
||||||
Python 2.3.4 or higher
|
|
||||||
|
|
||||||
* http://www.python.org/
|
* http://www.python.org/
|
||||||
|
|
||||||
@ -20,12 +15,14 @@ Prerequisites:
|
|||||||
|
|
||||||
* 2.2.x MIGHT work, or have partial functionality.
|
* 2.2.x MIGHT work, or have partial functionality.
|
||||||
|
|
||||||
|
* 2.4b2 seems to work fine.
|
||||||
|
|
||||||
* Red Hat Linux:
|
* Red Hat Linux:
|
||||||
|
|
||||||
o Make sure you have the Python development headers
|
- Make sure you have the Python development headers and libraries
|
||||||
and libraries (python-devel).
|
(python-devel).
|
||||||
|
|
||||||
MySQL 3.23.32 or higher
|
+ MySQL 3.23.32 or higher
|
||||||
|
|
||||||
* http://www.mysql.com/downloads/
|
* http://www.mysql.com/downloads/
|
||||||
|
|
||||||
@ -33,17 +30,17 @@ Prerequisites:
|
|||||||
|
|
||||||
* Versions lower than 3.22.19 might not work.
|
* Versions lower than 3.22.19 might not work.
|
||||||
|
|
||||||
* MySQL-4.1 and newer are not yet supported, and probably won't be
|
* MySQL-3.22 is deprecated in favor of 3.23, but still supported.
|
||||||
until MySQLdb-1.3 or 2.0. Current releases are 4.1.2 (alpha) and
|
|
||||||
5.0.0 (alpha). MySQLdb might work with these versions, but does
|
|
||||||
not yet support the prepared statements API.
|
|
||||||
|
|
||||||
* MySQL-4.0 is supported and prefered, and all recent testing is
|
|
||||||
with 4.0.x.
|
|
||||||
|
|
||||||
* MySQL-3.23 is supported, but slightly deprecated.
|
* MySQL-3.23 is supported, but slightly deprecated.
|
||||||
|
|
||||||
* MySQL-3.22 is deprecated in favor of 3.23, but still supported.
|
* MySQL-4.0 is supported. Current version is 4.0.22.
|
||||||
|
|
||||||
|
* There is partial support for MySQL-4.1; the new prepared
|
||||||
|
statements API is not yet supported, and probably won't be until
|
||||||
|
MySQLdb-1.3 or 2.0.
|
||||||
|
|
||||||
|
* MySQL-5.0 and newer are not currently supported, but might work.
|
||||||
|
|
||||||
* MaxDB, formerly known as SAP DB (and maybe Adabas D?), is a
|
* MaxDB, formerly known as SAP DB (and maybe Adabas D?), is a
|
||||||
completely different animal. Use the sapdb.sql module that comes
|
completely different animal. Use the sapdb.sql module that comes
|
||||||
@ -51,19 +48,19 @@ Prerequisites:
|
|||||||
|
|
||||||
* Red Hat Linux packages:
|
* Red Hat Linux packages:
|
||||||
|
|
||||||
o mysql-devel to compile
|
- mysql-devel to compile
|
||||||
|
|
||||||
o mysql and/or mysql-devel to run
|
- mysql and/or mysql-devel to run
|
||||||
|
|
||||||
* MySQL.com RPM packages:
|
* MySQL.com RPM packages:
|
||||||
|
|
||||||
o MySQL-devel to compile
|
- MySQL-devel to compile
|
||||||
|
|
||||||
o MySQL-shared if you want to use their shared
|
- MySQL-shared if you want to use their shared
|
||||||
library. Otherwise you'll get a statically-linked module,
|
library. Otherwise you'll get a statically-linked module,
|
||||||
which may or may not be what you want.
|
which may or may not be what you want.
|
||||||
|
|
||||||
o MySQL-shared to run if you compiled with MySQL-shared installed
|
- MySQL-shared to run if you compiled with MySQL-shared installed
|
||||||
|
|
||||||
* Transactions (particularly InnoDB tables) are supported for
|
* Transactions (particularly InnoDB tables) are supported for
|
||||||
MySQL-3.23 and up. You may need a special package from your
|
MySQL-3.23 and up. You may need a special package from your
|
||||||
@ -71,18 +68,22 @@ Prerequisites:
|
|||||||
set either of the berkdb or innodb USE flags.
|
set either of the berkdb or innodb USE flags.
|
||||||
|
|
||||||
|
|
||||||
zlib
|
+ zlib
|
||||||
|
|
||||||
* Required for MySQL-3.23 and newer.
|
* Required for MySQL-3.23 and newer.
|
||||||
|
|
||||||
* Red Hat Linux
|
* Red Hat Linux
|
||||||
|
|
||||||
o zlib-devel to compile
|
- zlib-devel to compile
|
||||||
|
|
||||||
o zlib to run
|
- zlib to run
|
||||||
|
|
||||||
|
+ openssl
|
||||||
|
|
||||||
A C COMPILER!!!
|
* May be needed for MySQL-4.0 or newer, depending on compilation
|
||||||
|
options.
|
||||||
|
|
||||||
|
+ C compiler
|
||||||
|
|
||||||
* Most free software-based systems already have this, usually gcc.
|
* Most free software-based systems already have this, usually gcc.
|
||||||
|
|
||||||
@ -93,140 +94,162 @@ Prerequisites:
|
|||||||
for this, or you can use Cygwin.
|
for this, or you can use Cygwin.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Building and installing
|
Building and installing
|
||||||
|
-----------------------
|
||||||
|
|
||||||
First thing to do is read setup.py. There are some variables towards
|
First thing to do is read setup.py. There are some variables towards
|
||||||
the beginning that tell it where your MySQL include files and
|
the beginning that tell it where your MySQL include files and
|
||||||
libraries are, compiler flags, loader flags, etc. You will rarely
|
libraries are, compiler flags, loader flags, etc. You will rarely have
|
||||||
have to change this unless you have some kind of weird setup.
|
to change this unless you have some kind of weird setup.
|
||||||
|
|
||||||
After the main variables section, there is some platform-specific
|
After the main variables section, there is some platform-specific
|
||||||
configuration. If your platform is not listed, this is where you
|
configuration. If your platform is not listed, this is where you want
|
||||||
want to add it. Note that most POSIX and UNIX-ish systems will work
|
to add it. Note that most POSIX and UNIX-ish systems will work just
|
||||||
just fine the way it is.
|
fine the way it is.
|
||||||
|
|
||||||
Depending on which version of MySQL you have, you may have the
|
Depending on which version of MySQL you have, you may have the option
|
||||||
option of using three different client libraries:
|
of using three different client libraries:
|
||||||
|
|
||||||
mysqlclient -- mostly but not guaranteed thread-safe
|
mysqlclient
|
||||||
|
mostly but not guaranteed thread-safe
|
||||||
|
|
||||||
mysqlclient_r -- thread-safe, use if you can
|
mysqlclient_r
|
||||||
|
thread-safe, use if you can
|
||||||
|
|
||||||
mysqld -- embedded server
|
mysqld
|
||||||
|
embedded server
|
||||||
|
|
||||||
mysqlclient is used by default. To use one of the others, set
|
mysqlclient is used by default. To use one of the others, set
|
||||||
the environment variable mysqlclient to the name of the library
|
the environment variable mysqlclient to the name of the library
|
||||||
you want to use.
|
you want to use. In a Bourne-style shell, use::
|
||||||
|
|
||||||
There are several active versions of MySQL out there, and this
|
$ export mysqlclient=mysqlclient_r
|
||||||
makes it a little tricky to configure setup.py automatically and
|
|
||||||
still be cross-platform. setup.py assumes you are using version
|
|
||||||
4.0.20. To specify a different version, set the environment
|
|
||||||
variable mysqlversion.
|
|
||||||
|
|
||||||
If your MySQL is compiled with certain options, you may need to
|
There are several active versions of MySQL out there, and this makes
|
||||||
add some more libraries to the link. In particular, with 4.0 and
|
it a little tricky to configure setup.py automatically and still be
|
||||||
up, if MySQL was configured to use SSL, you need to link against
|
cross-platform. setup.py assumes you are using version 4.0.20. To
|
||||||
crypto and ssl. You can do this by setting the environment
|
specify a different version, set the environment variable
|
||||||
variable mysqloptlibs a space-separated list of libraries.
|
mysqlversion.
|
||||||
|
|
||||||
If you have the dynamic client libraries (on Linux, .so vs. .a),
|
If your MySQL is compiled with certain options, you may need to add
|
||||||
those will be used by default. If they are not on your standard
|
some more libraries to the link. In particular, with 4.0 and up, if
|
||||||
loader path, you will have to set or adjust the LD_LIBRARY_PATH
|
MySQL was configured to use SSL, you need to link against crypto and
|
||||||
environment variable (on Linux) or whatever your platform
|
ssl. You can do this by setting the environment variable mysqloptlibs
|
||||||
requires. Otherwise, you can adjust setup.py to link against the
|
a space-separated list of libraries.
|
||||||
static library. If you are using standard RPM packaging, you
|
|
||||||
shouldn't have to mess with this. If you compiled MySQL yourself,
|
|
||||||
you might. There is a runtime_libraries_dir variable you can play
|
|
||||||
with, but this does not work on all system; in particular, it
|
|
||||||
doesn't seem to work on Linux gcc.
|
|
||||||
|
|
||||||
Finally, putting it together:
|
If you have the dynamic client libraries (on Linux, .so vs. .a), those
|
||||||
|
will be used by default. If they are not on your standard loader path,
|
||||||
|
you will have to set or adjust the LD_LIBRARY_PATH environment
|
||||||
|
variable (on Linux) or whatever your platform requires. Otherwise, you
|
||||||
|
can adjust setup.py to link against the static library. If you are
|
||||||
|
using standard RPM packaging, you shouldn't have to mess with this. If
|
||||||
|
you compiled MySQL yourself, you might. There is a
|
||||||
|
runtime_libraries_dir variable you can play with, but this does not
|
||||||
|
work on all system; in particular, it doesn't seem to work on Linux
|
||||||
|
gcc.
|
||||||
|
|
||||||
$ tar xfz MySQL-python-1.1.2.tar.gz
|
Finally, putting it together::
|
||||||
$ cd MySQL-python-1.1.2
|
|
||||||
|
$ tar xfz MySQL-python-1.1.7.tar.gz
|
||||||
|
$ cd MySQL-python-1.1.7
|
||||||
$ export mysqlversion="4.0.20"
|
$ export mysqlversion="4.0.20"
|
||||||
$ export mysqlclient="mysqlclient_r"
|
$ export mysqlclient="mysqlclient_r"
|
||||||
$ export mysqloptlibs="ssl crypto"
|
$ export mysqloptlibs="ssl crypto"
|
||||||
$ python setup.py build
|
$ python setup.py build
|
||||||
$ su
|
$ su # or use sudo
|
||||||
# python setup.py install
|
# python setup.py install
|
||||||
|
|
||||||
NOTE: You must export environment variables for setup.py to see
|
NOTE: You must export environment variables for setup.py to see them.
|
||||||
them. Depending on what shell you prefer, you may need to use
|
Depending on what shell you prefer, you may need to use "export" or
|
||||||
"export" or "set -x" (bash and other Bourne-like shells) or "setenv"
|
"set -x" (bash and other Bourne-like shells) or "setenv" (csh-like
|
||||||
(csh-like shells).
|
shells).
|
||||||
|
|
||||||
Windows
|
Windows
|
||||||
|
.......
|
||||||
|
|
||||||
I don't do Windows. However if someone provides me with a package
|
I don't do Windows. However if someone provides me with a package for
|
||||||
for Windows, I'll make it available. Don't ask me for help with
|
Windows, I'll make it available. Don't ask me for help with Windows
|
||||||
Windows because I can't help you.
|
because I can't help you.
|
||||||
|
|
||||||
|
|
||||||
Zope
|
Zope
|
||||||
|
....
|
||||||
|
|
||||||
If you are using a binary package of Zope, you need run setup.py
|
If you are using a binary package of Zope, you need run setup.py with
|
||||||
with the python executable that came with Zope. Otherwise, you'll
|
the python executable that came with Zope. Otherwise, you'll install
|
||||||
install into the wrong Python tree and Zope (ZMySQLDA) will not be
|
into the wrong Python tree and Zope (ZMySQLDA) will not be able to
|
||||||
able to find _mysql.
|
find _mysql.
|
||||||
|
|
||||||
With zope.org's Zope-2.5.1-linux2-x86 binary tarball, you'd do
|
With zope.org's Zope-2.5.1-linux2-x86 binary tarball, you'd do
|
||||||
something like this:
|
something like this::
|
||||||
|
|
||||||
$ export ZOPEBIN=".../Zope-2.5.1-linux2-x86/bin" # wherever you unpacked it
|
$ export ZOPEBIN=".../Zope-2.5.1-linux2-x86/bin" # wherever you unpacked it
|
||||||
$ $ZOPEBIN/python setup.py install # builds and installs
|
$ $ZOPEBIN/python setup.py install # builds and installs
|
||||||
|
|
||||||
|
|
||||||
RPMs
|
Binary Packages
|
||||||
|
---------------
|
||||||
|
|
||||||
If you prefer RPMs, you can use the bdist_rpm command with
|
I don't plan to make binary packages any more. However, if someone
|
||||||
setup.py. This only builds the RPM; it does not install it. You
|
contributes one, I will make it available. Several OS vendors have
|
||||||
may want to use the --python=XXX option, where XXX is the name of
|
their own packages available.
|
||||||
the Python executable, i.e. python, python2, python2.1; the
|
|
||||||
default is python. Using this will incorporate the Python
|
|
||||||
executable name into the package name for the RPM so you have
|
|
||||||
install the package multiple times if you need to support more
|
|
||||||
than one version of Python.
|
|
||||||
|
|
||||||
|
|
||||||
Red Hat Linux
|
RPMs
|
||||||
|
....
|
||||||
|
|
||||||
MySQL-python is pre-packaged in Red Hat Linux 7.x and newer. This
|
If you prefer to install RPMs, you can use the bdist_rpm command with
|
||||||
likely includes Fedora Core and Red Hat Enterprise Linux.
|
setup.py. This only builds the RPM; it does not install it. You may
|
||||||
|
want to use the --python=XXX option, where XXX is the name of the
|
||||||
|
Python executable, i.e. python, python2, python2.1; the default is
|
||||||
|
python. Using this will incorporate the Python executable name into
|
||||||
|
the package name for the RPM so you have install the package multiple
|
||||||
|
times if you need to support more than one version of Python.
|
||||||
|
|
||||||
|
|
||||||
Debian GNU/Linux
|
Red Hat Linux
|
||||||
|
.............
|
||||||
|
|
||||||
Packaged as python-mysql.
|
MySQL-python is pre-packaged in Red Hat Linux 7.x and newer. This
|
||||||
|
likely includes Fedora Core and Red Hat Enterprise Linux. You can also
|
||||||
|
build your own RPM packages as described above.
|
||||||
|
|
||||||
http://www.debian.org/distrib/packages
|
|
||||||
|
|
||||||
Gentoo Linux
|
Debian GNU/Linux
|
||||||
|
................
|
||||||
|
|
||||||
It's in the portage tree. Gentoo is also my development platform.
|
Packaged as `python-mysql`__::
|
||||||
|
|
||||||
|
# apt-get install python-mysql
|
||||||
|
|
||||||
|
.. __: http://packages.debian.org/cgi-bin/search_packages.pl?keywords=python-mysql&searchon=names&subword=1&version=all&release=all
|
||||||
|
|
||||||
|
|
||||||
|
Gentoo Linux
|
||||||
|
............
|
||||||
|
|
||||||
|
Packaged as `mysql-python`__. Gentoo is also my development platform::
|
||||||
|
|
||||||
# emerge sync
|
# emerge sync
|
||||||
# emerge mysql-python
|
# emerge mysql-python
|
||||||
# emerge zmysqlda # if you use Zope
|
# emerge zmysqlda # if you use Zope
|
||||||
|
|
||||||
*BSD
|
.. __: http://packages.gentoo.org/search/?sstring=mysql-python
|
||||||
|
|
||||||
MySQL-python is a ported package in FreeBSD, NetBSD, and OpenBSD,
|
|
||||||
although the name may vary to match OS conventions.
|
|
||||||
|
|
||||||
|
|
||||||
Acknowledgements
|
BSD
|
||||||
|
...
|
||||||
|
|
||||||
Thanks go to Brian Fordham for cooking up an early version of setup.py.
|
MySQL-python is a ported package in FreeBSD, NetBSD, and OpenBSD,
|
||||||
|
although the name may vary to match OS conventions.
|
||||||
See the CHANGELOG for other individual contributions.
|
|
||||||
|
|
||||||
|
|
||||||
License
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
GPL or the original license based on Python 1.5.2's license.
|
GPL or the original license based on Python 1.5.2's license.
|
||||||
|
|
||||||
|
|
||||||
Andy Dustman <andy@dustman.net>
|
:Author: Andy Dustman <andy@dustman.net>
|
||||||
2004-06-06 (D-Day + 60)
|
:Revision: $Id$
|
||||||
|
Reference in New Issue
Block a user