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 ~] # Pythonpython 2.7.3 (default, Jul 18 2013, 20:53:58) [GCC 3.4.6 20060404 (Red Hat 3.4.6-3.1)] on linux2type "help", "Copyright ", "Credits" or "License" for more information. >>> import MySQL. connector >>> CNX = MySQL. connector. connect (user = 'waterbin', password = '000000', host = '000000. 168.1.115', database = 'test') >>> cur = CNX. cursor () >>> cur.exe cute ('select * from t') >>> print cur. fetchall () [(1,)]
 
>>> CNX. Close ()

By dba_waterbin

2013-07-25

Good luck

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.