Spaces:
Sleeping
Sleeping
File size: 1,216 Bytes
2d50b2f e58ce62 2d50b2f e58ce62 2d50b2f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
from evaluate import load
import sqlite3
module = load("Fritz02/execution_accuracy")
# Create connection to the database
database_path = "database.sqlite"
connection = sqlite3.connect(database_path)
# Cursor
cursor = connection.cursor()
# Create table
cursor.execute('''CREATE TABLE IF NOT EXISTS Player
(PlayerID INTEGER PRIMARY KEY,
PlayerName TEXT NOT NULL);''')
# Insert a row of data
cursor.execute("INSERT INTO Player VALUES (1, 'Cristiano Ronaldo')")
cursor.execute("INSERT INTO Player VALUES (2, 'Lionel Messi')")
# Define the function that will execute the SQL queries
def execute(sql_query):
# Execute the SQL queries
cursor.execute(sql_query)
result = cursor.fetchall()
return result
sql_queries_pred = [
"SELECT COUNT(*) FROM Player WHERE PlayerName = 'Cristiano Ronaldo'",
"SELECT COUNT(*) FROM Player WHERE PlayerName = 'Lionel Messi'"
]
sql_queries_ref = [
"SELECT COUNT(*) FROM Player WHERE PlayerName = 'Cristiano Ronaldo'",
"SELECT COUNT(*) FROM Player WHERE PlayerName = 'Lionel Messi'"
]
# Compute the score
results = module.compute(predictions=sql_queries_pred, references=sql_queries_ref, execute_func=execute)
print(results) |