Python连接Mysql数据

it2022-05-05  141

#coding=utf-8 import sys import MySQLdb db = MySQLdb.connect("localhost", "root", "root", "test", charset='utf8' ) cursor = db.cursor() sql= "select * from runlist where issendmail=0 limit 1" cursor.execute(sql) data = cursor.fetchone() try: if data!=None: #数据不为空 print(data[1]) except ZeroDivisionError as e: print('发生了异常:',e)

Python简单连接Mysql数据库。

转载于:https://www.cnblogs.com/mzpython/p/11014307.html


最新回复(0)