python mysql
#!/usr/bin/python #-*- coding:utf-8 -*- import MySQLdb as mdb con=None try: con=mdb.connect('localhost','root','123','test') cur=con.cursor() cur.execute("select version()") data=cur.fetchone() print data finally: if con: con.close()
#!/usr/bin/python #-*- coding:utf-8 -*- import MySQLdb as mdb con=None try: con=mdb.connect('localhost','root','123','test') cur=con.cursor() cur.execute("select version()") data=cur.fetchone() print data finally: if con: con.close()