Install and test MySQL Connector/Python

Source: Internet
Author: User

Install Connector/Python:

# Wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-1.0.11.zip
# Unzip mysql-connector-python-1.0.11.zip
# Cd mysql-connector-python-1.0.11
# Python setup. py install

Test whether Connector/Python is installed:

>>> From distutils. sysconfig import get_python_lib
>>> Print get_python_lib ()
/Usr/local/lib/python2.7/site-packages

Small instance:

[Root @ obe11g ~] # Python
Python 2.7.3 (default, Jul 18 2013, 20:53:58)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> Import mysql. connector
>>> Cnx = mysql. connector. connect (user = 'waterbin', password = '000000', host = '192. 168.1.115', database = 'test ')
>>> Cur = cnx. cursor ()
>>> Cur.exe cute ('select * from t ')
>>> Print cur. fetchall ()
[(1,)]

>>> Cnx. close ()

For details about MySQL Connector/Python, click here
MySQL Connector/Python: click here

Related Article

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.