2025-04-27 17:33:09 +08:00

31 lines
731 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pymysql
class Tool:
id = 0
name = ""
typeid = 0
def __init__(self, id, typeid):
self.id = id
self.typeid = typeid
def get_tool_name(id):
conn=pymysql.connect(host = '192.168.31.9' # 连接名称,默认
,user = 'saipo'
,passwd='Grasste0403' # 密码
,port= 3306 # 端口默认为3306
,db='saipo' # 数据库名称
,charset='utf8' # 字符编码
)
cur = conn.cursor()
sql = "SELECT name FROM dajiaotool WHERE id = %s"
cur.execute(sql, (id,))
result = cur.fetchone()
cur.close()
conn.close()
if result:
return result[0]
else:
return None