import sqlite3
conn = sqlite3.connect("/var/lib/grafana/grafana.db") # 连接数据库 cursor = conn.cursor() # 创建游标 cursor.execute("select id from user where name = '%s'"% user_name) # 执行语句 user_id = cursor.fetchall() # 拿到结果
import sqlite3
conn = sqlite3.connect("/var/lib/grafana/grafana.db") # 连接数据库 cursor = conn.cursor() # 创建游标 cursor.execute("select id from user where name = '%s'"% user_name) # 执行语句 user_id = cursor.fetchall() # 拿到结果