Python2.7 连接Mysql数据库
2013-01-12 22:14
459 查看
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> conn = MySQLdb.connect(host='172.16.67.22',
... user='root',
... passwd='***********'
... db='test')
>>> cursor = conn.cursor()
>>> cursor.execute("SELECT VERSION()")
1L
>>> row = cursor.fetchone()
>>> print "server version:",row[0]
server version: 5.1.66
>>> cursor.close()
>>> conn.close()
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> conn = MySQLdb.connect(host='172.16.67.22',
... user='root',
... passwd='***********'
... db='test')
>>> cursor = conn.cursor()
>>> cursor.execute("SELECT VERSION()")
1L
>>> row = cursor.fetchone()
>>> print "server version:",row[0]
server version: 5.1.66
>>> cursor.close()
>>> conn.close()
相关文章推荐
- win7上python2.7连接mysql数据库
- Python2.7 连接Mysql数据库
- 解决Python2.7 连接MySQL数据库遇到'can't connect to MySQL server on 'localhost'(10061)'问题
- win7上python2.7连接mysql数据库
- win7上python2.7连接mysql数据库的方法
- 探究Ubuntu14.04下多版本Python下连接MySQL数据库的安装
- Windows+Python2.7+MySQL5.5+MySQL-python-1.2.3配置数据连接失败
- Python入门学习教程:数据库操作,连接MySql数据库
- python数据存储系列教程——python中mysql数据库操作:连接、增删查改、指令执行
- python连接mysql数据库
- win 下python2.7 pymssql连接ms sqlserver 2000
- python 连接mysql数据库
- 【Python】Windows平台下Python、Pydev连接Mysql数据库
- python连接mysql数据库示例(做增删改操作)
- python连接MySQL数据库
- Python3--MySQL数据库连接
- Python连接Mysql数据库
- python3.5连接mysql数据库
- Python学习:连接MySQL数据库
- Python的ORM框架SQLAlchemy使用入门(二)【连接MySql数据库】