MySQL Connector/Python 安装、测试
安装Connector/Python: # wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-1.0.11.zip# unzip m
安装Connector/Python:
# wget
# 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 的下载地址:请点这里
推荐阅读
-
Python操作MySQL数据库实例详解【安装、连接、增删改查等】
-
python网站开发准备ubuntu14.04安装mysql实现windows管理
-
解决Ubuntu pip 安装 mysql-python包出错的问题
-
python虚拟环境virtualenv下安装MySQL-python(1.2.3)
-
Python下的Mysql模块MySQLdb安装详解
-
Mac安装MySQL-python的血泪史
-
Python的mysql操作之安装、链接教程
-
centos7安装mysql并jdbc测试实例详解
-
python测试mysql写入性能完整实例
-
Linux下安装Python3和django并配置mysql作为django默认服务器方法