Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,35 +26,43 @@ def fetch_personalized_data():
|
|
| 26 |
session_index = "eb3636167d3a63fbeee32934610e5b2f"
|
| 27 |
print(session_index)
|
| 28 |
playerNr = "1"
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
# Fetch all rows and convert to a list of dictionaries
|
| 56 |
rows = cursor.fetchall()
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
for row in rows:
|
| 59 |
d = {}
|
| 60 |
for i, col in enumerate(cursor.description):
|
|
|
|
| 26 |
session_index = "eb3636167d3a63fbeee32934610e5b2f"
|
| 27 |
print(session_index)
|
| 28 |
playerNr = "1"
|
| 29 |
+
|
| 30 |
+
try:
|
| 31 |
+
# Query to fetch relevant data from both tables based on session_index
|
| 32 |
+
query = f"""
|
| 33 |
+
SELECT
|
| 34 |
+
{core_table}.playerNr,
|
| 35 |
+
{core_table}.subjectNr,
|
| 36 |
+
{core_table}.onPage,
|
| 37 |
+
{decisions_table}.transfer1,
|
| 38 |
+
{decisions_table}.tripledAmount1,
|
| 39 |
+
{decisions_table}.keptForSelf1,
|
| 40 |
+
{decisions_table}.returned1,
|
| 41 |
+
{decisions_table}.newCreditRound2,
|
| 42 |
+
{decisions_table}.transfer2,
|
| 43 |
+
{decisions_table}.tripledAmount2,
|
| 44 |
+
{decisions_table}.keptForSelf2,
|
| 45 |
+
{decisions_table}.returned2,
|
| 46 |
+
{decisions_table}.resultsWithoutAI
|
| 47 |
+
FROM {core_table}
|
| 48 |
+
JOIN {decisions_table} ON
|
| 49 |
+
{core_table}.playerNr = {decisions_table}.playerNr AND
|
| 50 |
+
{core_table}.groupNr = {decisions_table}.groupNr AND
|
| 51 |
+
{core_table}.subjectNr = {decisions_table}.subjectNr
|
| 52 |
+
WHERE {decisions_table}.session_index = '{session_index}'
|
| 53 |
+
"""
|
| 54 |
+
cursor.execute(query)
|
| 55 |
+
print(cursor.statement)
|
| 56 |
+
print("Query executed successfully!")
|
| 57 |
+
except mysql.connector.Error as err:
|
| 58 |
+
print(f"Error executing query: {err}")
|
| 59 |
+
return None
|
| 60 |
|
| 61 |
# Fetch all rows and convert to a list of dictionaries
|
| 62 |
rows = cursor.fetchall()
|
| 63 |
+
if not rows:
|
| 64 |
+
print("No rows found for the given session_index.")
|
| 65 |
+
return noresult = []
|
| 66 |
for row in rows:
|
| 67 |
d = {}
|
| 68 |
for i, col in enumerate(cursor.description):
|