Spaces:
Sleeping
Sleeping
alexanderHSG commited on
Commit ·
869ab8d
1
Parent(s): f324609
add MySQL
Browse files- app.py +21 -1
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -10,6 +10,7 @@ from dotenv import load_dotenv
|
|
| 10 |
import sqlite3
|
| 11 |
from datetime import datetime
|
| 12 |
import re
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
|
|
@@ -26,6 +27,7 @@ driver = GraphDatabase.driver(neo4j_url, auth=AUTH)
|
|
| 26 |
|
| 27 |
|
| 28 |
|
|
|
|
| 29 |
user_id = None
|
| 30 |
|
| 31 |
|
|
@@ -261,9 +263,27 @@ def coordinate_simcalculation(storyline_output_storypoint_name_list):
|
|
| 261 |
def track_user_interaction(user_input, action):
|
| 262 |
global user_id
|
| 263 |
|
|
|
|
| 264 |
user_id = str(user_id)
|
| 265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
cursor = connection.cursor()
|
|
|
|
|
|
|
| 267 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 268 |
user_input_str = str(user_input)
|
| 269 |
action_str = str(action)
|
|
|
|
| 10 |
import sqlite3
|
| 11 |
from datetime import datetime
|
| 12 |
import re
|
| 13 |
+
import mysql.connector
|
| 14 |
|
| 15 |
|
| 16 |
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
+
|
| 31 |
user_id = None
|
| 32 |
|
| 33 |
|
|
|
|
| 263 |
def track_user_interaction(user_input, action):
|
| 264 |
global user_id
|
| 265 |
|
| 266 |
+
|
| 267 |
user_id = str(user_id)
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
# Construct connection string
|
| 271 |
+
from mysql.connector import errorcode
|
| 272 |
+
|
| 273 |
+
try:
|
| 274 |
+
connection = mysql.connector.connect(user=os.getenv("MYSQLUSER"), password= os.getenv("MYSQLPASSWORD"), host=os.getenv("DBHOST"), port=3306, database="user_interact")
|
| 275 |
+
print("Connection established")
|
| 276 |
+
except mysql.connector.Error as err:
|
| 277 |
+
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
|
| 278 |
+
print("Something is wrong with the user name or password")
|
| 279 |
+
elif err.errno == errorcode.ER_BAD_DB_ERROR:
|
| 280 |
+
print("Database does not exist")
|
| 281 |
+
else:
|
| 282 |
+
print(err)
|
| 283 |
+
|
| 284 |
cursor = connection.cursor()
|
| 285 |
+
|
| 286 |
+
|
| 287 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 288 |
user_input_str = str(user_input)
|
| 289 |
action_str = str(action)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
openai
|
| 2 |
neo4j
|
| 3 |
-
scikit-learn
|
|
|
|
|
|
| 1 |
openai
|
| 2 |
neo4j
|
| 3 |
+
scikit-learn
|
| 4 |
+
mysql-connector-python
|