import sqlite3
conn = sqlite3.connect("/var/lib/grafana/grafana.db") # connect to the database cursor = conn.cursor() # create a cursor cursor.execute("select id from user where name = '%s'"% user_name) # execute the statement user_id = cursor.fetchall() # get the result