Update database.py
Browse files- database.py +5 -12
database.py
CHANGED
|
@@ -93,12 +93,10 @@ def end_session(session_id, end_time):
|
|
| 93 |
|
| 94 |
def add_interaction(user_id, input_text, detected_language, translated_text,
|
| 95 |
nlu_summary, timestamp):
|
| 96 |
-
p = _placeholder()
|
| 97 |
-
|
| 98 |
sql = (
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
)
|
| 103 |
|
| 104 |
params = (
|
|
@@ -110,13 +108,8 @@ def add_interaction(user_id, input_text, detected_language, translated_text,
|
|
| 110 |
timestamp
|
| 111 |
)
|
| 112 |
|
| 113 |
-
with
|
| 114 |
-
|
| 115 |
-
cursor = _run(conn, sql + " RETURNING id", params)
|
| 116 |
-
return cursor.fetchone()["id"]
|
| 117 |
-
else:
|
| 118 |
-
cursor = _run(conn, sql, params)
|
| 119 |
-
return cursor.lastrowid
|
| 120 |
|
| 121 |
|
| 122 |
def get_interactions_for_user(user_id):
|
|
|
|
| 93 |
|
| 94 |
def add_interaction(user_id, input_text, detected_language, translated_text,
|
| 95 |
nlu_summary, timestamp):
|
|
|
|
|
|
|
| 96 |
sql = (
|
| 97 |
+
"INSERT INTO interaction "
|
| 98 |
+
"(user_id, input_text, detected_language, translated_text, nlu_summary, timestamp) "
|
| 99 |
+
"VALUES (?, ?, ?, ?, ?, ?)"
|
| 100 |
)
|
| 101 |
|
| 102 |
params = (
|
|
|
|
| 108 |
timestamp
|
| 109 |
)
|
| 110 |
|
| 111 |
+
with get_connection() as connection:
|
| 112 |
+
return _insert_and_get_id(connection, sql, params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
|
| 115 |
def get_interactions_for_user(user_id):
|