下载源码包
解压,vi README
之后进行安装:
$ tar xfz MySQL-python-1.2.1.tar.gz
$ cd MySQL-python-1.2.1
$ # edit site.cfg if necessary
$ python setup.py build
$ sudo python setup.py install # or su first
编译的时候没有成功,之后上goolge查了一下,要修改一下site.cfg 文件,要把threadsafe = True改成 False
之后就重新安装成功
弄个简单的脚本测试一下:
#!/usr/bin/python
import os, sys, string
import MySQLdb
try:
conn = MySQLdb.connect(host='localhost',user='xxx',passwd='xxx',db='test')
except Exception, e:
print e
sys.exit()
cursor = conn.cursor()
sql = "select * from table"
cursor.execute(sql)
data = cursor.fetchall()
if data:
for r in data:
print "%s ==> %s" % (r[0],r[1])
cursor.close()
conn.close()
解压,vi README
之后进行安装:
$ tar xfz MySQL-python-1.2.1.tar.gz
$ cd MySQL-python-1.2.1
$ # edit site.cfg if necessary
$ python setup.py build
$ sudo python setup.py install # or su first
编译的时候没有成功,之后上goolge查了一下,要修改一下site.cfg 文件,要把threadsafe = True改成 False
之后就重新安装成功
弄个简单的脚本测试一下:
#!/usr/bin/python
import os, sys, string
import MySQLdb
try:
conn = MySQLdb.connect(host='localhost',user='xxx',passwd='xxx',db='test')
except Exception, e:
print e
sys.exit()
cursor = conn.cursor()
sql = "select * from table"
cursor.execute(sql)
data = cursor.fetchall()
if data:
for r in data:
print "%s ==> %s" % (r[0],r[1])
cursor.close()
conn.close()