CoolFace
Apppublic

Fritz02/execution_accuracy

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
test.py43 linesDownload Raw Back to root
1from evaluate import load2import sqlite33 4module = load("Fritz02/execution_accuracy")5 6# Create connection to the database7database_path = "database.sqlite"8connection = sqlite3.connect(database_path)9# Cursor10cursor = connection.cursor()11 12# Create table13cursor.execute('''CREATE TABLE IF NOT EXISTS Player14             (PlayerID INTEGER PRIMARY KEY,15             PlayerName TEXT NOT NULL);''')16 17# Insert a row of data18cursor.execute("INSERT INTO Player VALUES (1, 'Cristiano Ronaldo')")19cursor.execute("INSERT INTO Player VALUES (2, 'Lionel Messi')")20 21 22# Define the function that will execute the SQL queries23def execute(sql_query):24    # Execute the SQL queries25 26    cursor.execute(sql_query)27    result = cursor.fetchall()28    return result29 30 31sql_queries_pred = [32    "SELECT COUNT(*) FROM Player WHERE PlayerName = 'Cristiano Ronaldo'",33    "SELECT COUNT(*) FROM Player WHERE PlayerName = 'Lionel Messi'"34]35 36sql_queries_ref = [37    "SELECT COUNT(*) FROM Player WHERE PlayerName = 'Cristiano Ronaldo'",38    "SELECT COUNT(*) FROM Player WHERE PlayerName = 'Lionel Messi'"39]40 41# Compute the score42results = module.compute(predictions=sql_queries_pred, references=sql_queries_ref, execute_func=execute)43print(results)