Spaces:
Sleeping
Sleeping
File size: 919 Bytes
7b1cbee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import streamlit as st
import pandas as pd
import sqlite3
from datetime import datetime
def app():
st.title('SQL Training')
st.write('SQL ์ฐ์ต์ ํด๋ด
์๋ค.')
file_name = st.text_input('file name:', )
# ์์
ํ์ผ ์
๋ก๋
user_query = st.text_area('Enter your SQL query:', height = 100)
if st.button('์ฟผ๋ฆฌ ์คํ'):
try:
# ์ฟผ๋ฆฌ ์คํ ๋ฐ ๊ฒฐ๊ณผ ์ถ๋ ฅ
conn = sqlite3.connect(file_name)
c = conn.cursor()
query_results = pd.read_sql_query(user_query, conn)
if not query_results.empty:
st.dataframe(query_results)
else:
st.write('์ฟผ๋ฆฌ๋ ์ฑ๊ณต์ ์ผ๋ก ์คํ๋์์ต๋๋ค. ๊ทธ๋ฌ๋ ๊ฒฐ๊ณผ๊ฐ ์๋ค์.')
except Exception as e:
st.error(f'์๋ฌ๊ฐ ๋ฐ์ํ์ต๋๋ค: {e}')
finally:
conn.close()
|