導入pymysql.cursors
導入json
類操作Mysql:
def __init__(self):
self.conn = pymysql.connect(
host='127.0.0.1 ',
端口=3306,
用戶= '測試',
passwd = ' 11111 ',
db= '測試',
charset='utf8 ',
cursor class = pymysql . cursors . dict cursor
)
self.cur = self.conn.cursor()
#查詢壹條數據
def search_one(self,sql):
自我.當前.執行(sql)
result = self.cur.fetchone()
回送結果
#更新SQL
def updata_one(self,sql):
自我.當前.執行(sql)
self.conn.commit()
self.conn.close()
if __name__ == '__main__ ':
op_mysql = OperationMysql()
RES = op _ MySQL . search _ one(" SELECT * from order WHERE order _ no = ' m 191023401681654 ' ")
打印(分辨率)