mysql connector python linux_MySQL Connector/Python 安装、测试
安裝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
測(cè)試Connector/Python是否裝上:
>>> from distutils.sysconfig import get_python_lib
>>> print get_python_lib()
/usr/local/lib/python2.7/site-packages
小實(shí)例:
[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 的詳細(xì)介紹:請(qǐng)點(diǎn)這里
MySQL Connector/Python 的下載地址:請(qǐng)點(diǎn)這里
總結(jié)
以上是生活随笔為你收集整理的mysql connector python linux_MySQL Connector/Python 安装、测试的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 求个图片。。。?
- 下一篇: 机动奥特曼电影啥时候播出