1,import MySQLdb module
2. 打开连接
db =MySQLdb.connect("localhost","testuser","test123","TESTDB" )
3. 打开游标
cursor = db.cursor()
4. 执行sql
cursor.execute("SELECT VERSION()")
5. 获取一条数据
data = cursor.fetchone()
1,import MySQLdb module
2. 打开连接
db =MySQLdb.connect("localhost","testuser","test123","TESTDB" )
3. 打开游标
cursor = db.cursor()
4. 执行sql
cursor.execute("SELECT VERSION()")
5. 获取一条数据
data = cursor.fetchone()
转载于:https://my.oschina.net/hanruikai/blog/341968