安装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()
By DBA_WaterBin
2013-07-25
Good Luck
安装与使用MySQL Connector/Python
本文介绍如何安装MySQL Connector/Python并提供了一个简单的使用示例。通过wget下载指定版本的压缩包,解压并进入目录后使用python setup.py install完成安装。安装成功后可以通过Python导入mysql.connector模块并连接到MySQL数据库。
1392

被折叠的 条评论
为什么被折叠?



