Update sample_benchmarks.py
Browse files- sample_benchmarks.py +18 -12
sample_benchmarks.py
CHANGED
@@ -4,12 +4,12 @@ Sample benchmarks initialization for Dynamic Highscores system.
|
|
4 |
This script adds sample benchmarks to the database to provide initial options for users.
|
5 |
"""
|
6 |
|
7 |
-
from database_schema import
|
8 |
|
9 |
def add_sample_benchmarks():
|
10 |
"""Add sample benchmarks to the database."""
|
11 |
# Initialize database
|
12 |
-
db =
|
13 |
|
14 |
# Sample benchmarks to add
|
15 |
sample_benchmarks = [
|
@@ -46,21 +46,27 @@ def add_sample_benchmarks():
|
|
46 |
]
|
47 |
|
48 |
# Add each benchmark to the database
|
|
|
49 |
for benchmark in sample_benchmarks:
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
# Close database connection
|
60 |
db.close()
|
61 |
|
62 |
-
return
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
num_added = add_sample_benchmarks()
|
66 |
-
print(f"Added {num_added} sample benchmarks to the database.")
|
|
|
4 |
This script adds sample benchmarks to the database to provide initial options for users.
|
5 |
"""
|
6 |
|
7 |
+
from database_schema import DynamicHighscoresDB
|
8 |
|
9 |
def add_sample_benchmarks():
|
10 |
"""Add sample benchmarks to the database."""
|
11 |
# Initialize database
|
12 |
+
db = DynamicHighscoresDB()
|
13 |
|
14 |
# Sample benchmarks to add
|
15 |
sample_benchmarks = [
|
|
|
46 |
]
|
47 |
|
48 |
# Add each benchmark to the database
|
49 |
+
added_count = 0
|
50 |
for benchmark in sample_benchmarks:
|
51 |
+
try:
|
52 |
+
benchmark_id = db.add_benchmark(
|
53 |
+
name=benchmark["name"],
|
54 |
+
dataset_id=benchmark["dataset_id"],
|
55 |
+
description=benchmark["description"],
|
56 |
+
metrics=benchmark["metrics"]
|
57 |
+
)
|
58 |
+
|
59 |
+
if benchmark_id:
|
60 |
+
print(f"Added benchmark '{benchmark['name']}' with ID: {benchmark_id}")
|
61 |
+
added_count += 1
|
62 |
+
except Exception as e:
|
63 |
+
print(f"Error adding benchmark '{benchmark['name']}': {e}")
|
64 |
|
65 |
# Close database connection
|
66 |
db.close()
|
67 |
|
68 |
+
return added_count
|
69 |
|
70 |
if __name__ == "__main__":
|
71 |
num_added = add_sample_benchmarks()
|
72 |
+
print(f"Added {num_added} sample benchmarks to the database.")
|