botsi commited on
Commit
6e2bdf1
·
verified ·
1 Parent(s): ee1def5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -58
app.py CHANGED
@@ -8,59 +8,6 @@ import csv
8
  from datetime import datetime
9
  from huggingface_hub import Repository, hf_hub_download
10
 
11
- '''def fetch_personalized_data():
12
- # Connect to the database
13
- conn = mysql.connector.connect(
14
- host="18.153.94.89",
15
- user="root",
16
- password="N12RXMKtKxRj",
17
- database="lionessdb"
18
- )
19
-
20
- # Create a cursor object
21
- cursor = conn.cursor(dictionary=True) # Use dictionary cursor for easier data manipulation
22
-
23
- # Replace the placeholders with your actual database and table names
24
- core_table = "e5390g37096_core"
25
- decisions_table = "e5390g37096_decisions"
26
- session_index = "eb3636167d3a63fbeee32934610e5b2f"
27
-
28
- # Query to fetch relevant data from both tables based on session_index
29
- query = f"""
30
- SELECT e5390g37096_core.playerNr,
31
- e5390g37096_core.groupNr,
32
- e5390g37096_core.subjectNr
33
- FROM e5390g37096_core
34
- JOIN e5390g37096_decisions ON
35
- e5390g37096_core.playerNr = e5390g37096_decisions.playerNr
36
- WHERE e5390g37096_decisions.session_index = '{session_index}'
37
- """
38
-
39
- try:
40
- cursor.execute(query)
41
-
42
- # Fetch all rows as dictionaries
43
- rows = cursor.fetchall()
44
-
45
- # Close the database connection
46
- conn.close()
47
-
48
- return rows # Return the fetched rows
49
-
50
- except mysql.connector.Error as err:
51
- print(f"Error: {err}")
52
- return None
53
-
54
- # Call the function to fetch data
55
- personalized_data = fetch_personalized_data()
56
-
57
- if personalized_data:
58
- for row in personalized_data:
59
- print(row) # Print each row
60
- else:
61
- print("No data found.")
62
- '''
63
-
64
  get_window_url_params = """
65
  function() {
66
  const params = new URLSearchParams(window.location.search);
@@ -92,10 +39,7 @@ with gr.Blocks() as demo:
92
  def bot(history, url_params):
93
  if "read query" in history[-1][0]:
94
  session_index = url_params.get('session_index')
95
- bot_message = f"""
96
- here your URL params:
97
- {json.dumps(url_params, indent=4)}
98
- """
99
  # Connect to the database
100
  conn = mysql.connector.connect(
101
  host="18.153.94.89",
@@ -133,7 +77,13 @@ with gr.Blocks() as demo:
133
  except mysql.connector.Error as err:
134
  print(f"Error: {err}")
135
  return None
136
-
 
 
 
 
 
 
137
  elif "print data" in history[-1][0]:
138
  personalized_data = fetch_personalized_data()
139
  print(personalized_data)
 
8
  from datetime import datetime
9
  from huggingface_hub import Repository, hf_hub_download
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  get_window_url_params = """
12
  function() {
13
  const params = new URLSearchParams(window.location.search);
 
39
  def bot(history, url_params):
40
  if "read query" in history[-1][0]:
41
  session_index = url_params.get('session_index')
42
+
 
 
 
43
  # Connect to the database
44
  conn = mysql.connector.connect(
45
  host="18.153.94.89",
 
77
  except mysql.connector.Error as err:
78
  print(f"Error: {err}")
79
  return None
80
+
81
+ bot_message = f"""
82
+ here your URL params:
83
+ {json.dumps(url_params, indent=4)}
84
+ and those are your database results: {rows}
85
+ """
86
+
87
  elif "print data" in history[-1][0]:
88
  personalized_data = fetch_personalized_data()
89
  print(personalized_data)