Spaces:
Runtime error
Runtime error
Download test.py from Fritz02/execution_accuracy: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/Fritz02/execution_accuracy/resolve/main/test.py
- Command line
-
hf download hf://spaces/Fritz02/execution_accuracy/test.py
-
curl -L -o test.py https://huggingface.co/spaces/Fritz02/execution_accuracy/resolve/main/test.py
1.22 kB
| 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) |