MySQL in Python

Source: Internet
Author: User

Step 1: Install mysql-python-1.2.2.tar

Python setup. py build
Python setup. py intstall

Step 2: Possible Errors

1. libmysqlclient. so.16: cannot open shared object file: No such file or directory

Need to install a new package mysqlclient16-5.1.30-1.el5.remi.i386

Or set the link through ln-s.

2, in the build need to follow the setuptools-0.6b1-py2.4.egg package

% Wget-q http://peak.telecommunity.com/dist/ez_setup.py

% Python ez_setup.py
Downloading http://cheeseshop.python.org/packages/2.4/s/
Setuptools/setuptools-0.6b1-py2.4.egg # md5 = b79a8a403e%2fbb85ee3f19%35cb
Processing setuptools-0.6b1-py2.4.egg
Creating/sw/lib/python2.4/site-packages/setuptools-0.6b1-py2.4.egg
Extracting setuptools-0.6b1-py2.4.egg to/sw/lib/python2.4/site-packages
Removing setuptools 0.6a11 from a easy-install.pth file
Adding setuptools 0.6b1 to THE easy-install.pth file
Installing easy_install script to/sw/bin
Installing easy_install-2.4 script to/sw/bin.

Installed/sw/lib/python2.4/site-packages/setuptools-0.6b1-py2.4.egg
Processing dependencies for setuptools

To access the Internet as needed, you need to set the network environment IP address + DNS.

3 EnvironmentError: mysql_config not found

MySQL-python-1.2.2] # vi setup_posix.py
26 mysql_config.path = "/usr/local/mysql/bin/mysql_config"
Change 26 rows to the actual path of mysql_config
Run python setup. py build again; python setup. py install again
OK.

4/usr/bin/ld: cannot find-lmysqlclient_r
Solution 1 (tested)

Run the following command:

Echo "/usr/local/mysql/lib/mysql">/etc/ld. so. conf (my environment is CentOS 5)

Ldconfig. The above error is still prompted after execution.

--------

Later it seems that README, the original text is below

-------

Threadsafe
Thread-safe client library (libmysqlclient_r) if True (default );
Otherwise use non-thread-safe (libmysqlclient). You shocould
Always use the thread-safe library if you have the option;
Otherwise you * may * have problems.

-----------

We know that we have to modify site. cfg and set thread-safe to false. Everything is OK!

Python setup. py install

Solution 2 (not tested) A thread-safe client library (libmysqlclient_r) will be created automatically during the compilation of MySQL if the configure command contains the option "-- enable-thread-safe-client ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.