python连接mysql数据库

import MySQLdb
db = MySQLdb.connect("127.0.0.1","root","123")
cursor = db.cursor()
cmd = "select name from vmtables where id=1"
cursor.execute(cmd)
message = cursor.fetchone()
vmname = message[0]
db.close()

 

你可能感兴趣的:(python连接mysql数据库)