MySQL Connector/Python 安裝、測試

來源:互聯網
上載者:User

安裝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

測試Connector/Python是否裝上:

>>> from distutils.sysconfig import get_python_lib
>>> print get_python_lib()
/usr/local/lib/python2.7/site-packages

小執行個體:

[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='123',host='192.168.1.115',database='test')
>>> cur=cnx.cursor()
>>> cur.execute('select * from t')
>>> print cur.fetchall()
[(1,)]

>>> cnx.close()

MySQL Connector/Python 的詳細介紹:請點這裡
MySQL Connector/Python 的:請點這裡

相關文章

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.