Spaces:
Sleeping
Sleeping
database for comments connected
Browse files- pages/Summary.py +12 -1
pages/Summary.py
CHANGED
@@ -7,6 +7,7 @@ import pandas as pd
|
|
7 |
import pymysql.cursors
|
8 |
import streamlit as st
|
9 |
|
|
|
10 |
from streamlit_elements import elements, mui, html, dashboard, nivo
|
11 |
from streamlit_extras.switch_page_button import switch_page
|
12 |
from streamlit_extras.metric_cards import style_metric_cards
|
@@ -205,7 +206,17 @@ class DashboardApp:
|
|
205 |
tag = self.sidebar(tags, mode)
|
206 |
self.leaderboard(tag, db_table)
|
207 |
|
208 |
-
st.chat_input('Please leave your comments here.', key='comment')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
|
211 |
if __name__ == "__main__":
|
|
|
7 |
import pymysql.cursors
|
8 |
import streamlit as st
|
9 |
|
10 |
+
from datetime import datetime
|
11 |
from streamlit_elements import elements, mui, html, dashboard, nivo
|
12 |
from streamlit_extras.switch_page_button import switch_page
|
13 |
from streamlit_extras.metric_cards import style_metric_cards
|
|
|
206 |
tag = self.sidebar(tags, mode)
|
207 |
self.leaderboard(tag, db_table)
|
208 |
|
209 |
+
comment = st.chat_input('Please leave your comments here.', key='comment')
|
210 |
+
if comment:
|
211 |
+
commenttime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
212 |
+
curser = RANKING_CONN.cursor()
|
213 |
+
# parse the comment to at most 300 to avoid SQL injection
|
214 |
+
for i in range(0, len(comment), 300):
|
215 |
+
curser.execute(f"INSERT INTO comments (username, timestamp, comment, commenttime) VALUES ('{st.session_state.user_id[0]}', '{st.session_state.user_id[1]}', '{comment[i:i+300]}', '{commenttime}')")
|
216 |
+
RANKING_CONN.commit()
|
217 |
+
curser.close()
|
218 |
+
|
219 |
+
st.toast('Thanks for your feedback! We will take it into consideration in our future work.')
|
220 |
|
221 |
|
222 |
if __name__ == "__main__":
|