import
MySQLdb
try:
conn=MySQLdb.connect(host='localhost',user='root',passwd='root',port=3306)
cur=conn.cursor()
conn.select_db('python')
count=cur.execute('select *
from test')
'there has %s rows record' % count
result=cur.fetchone()
result
'ID: %s info %s' % result
results=cur.fetchmany(5)
for r in results:
r
'=='*10
cur.scroll(0,mode='absolute')
results=cur.fetchall()
for r in results:
r[1]
conn.commit()
cur.close()
conn.close()
except MySQLdb.Error,e:
"Mysql Error %d: %s" % (e.args[0], e.args[1])
1、mac x 下面自带的python 貌似是64位的。这个你得保证你自己确认一下。2、安装mysql,这个你可以去搜
提供软件名称,百度一搜就是了~~
mysql-5.5.29-osx10.6-x86_64.dmg
mysql-workbench-gpl-5.2.45-osx-i686.dmg
3、安装python-mysqldb
xampp改称lampp是因为和lampp环境名称有冲突。xampp:软件名,Apache + MySQL + PHP + Perl环境的一键安装程序。支持linux,windows和mac os x三种操作系统。
lampp:Linux+Apache+Mysql+PHP+Perl的系统环境。lampp环境基本上就等于lamp环境,因为linux默认都自带了perl环境。