Spaces:
Sleeping
Sleeping
Strauss Cunha Carvalho
commited on
Commit
·
72a1ca8
1
Parent(s):
daac352
dev:sqlite
Browse files
app.py
CHANGED
|
@@ -21,9 +21,7 @@ std_edp = 'https://huggingface.co/datasets/strauss-oak/afa-bd/resolve/main/tb-st
|
|
| 21 |
|
| 22 |
conn = sqlite3.connect("afa-db.db")
|
| 23 |
|
| 24 |
-
sql_example = """SELECT alu_id, alu_nome, alu_uf, alu_cep, progresso_alfabetizacao
|
| 25 |
-
FROM tb_students
|
| 26 |
-
WHERE progresso_alfabetizacao >= 6 LIMIT 100"""
|
| 27 |
|
| 28 |
txt_example = """Qual um dos estudantes com maior nota no estado de SP?"""
|
| 29 |
|
|
@@ -51,6 +49,14 @@ def refresh_data_students():
|
|
| 51 |
df_std = df_std[:10]
|
| 52 |
return df_std, n_std
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
st.info('Amostras de Dados:')
|
| 55 |
e1 = st.expander('Professores:', expanded=False)
|
| 56 |
with e1:
|
|
@@ -74,10 +80,16 @@ st.info('Consultas:')
|
|
| 74 |
e4 = st.expander('Linguagem SQL:', expanded=False)
|
| 75 |
with e4:
|
| 76 |
sql = st.text_input("Digite uma instrução SQL válida:", sql_example)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
e5 = st.expander('Linguagem Natural:', expanded=False)
|
| 79 |
with e5:
|
| 80 |
txt = st.text_input("Digite um texto de consulta válido:", txt_example)
|
|
|
|
|
|
|
| 81 |
|
| 82 |
|
| 83 |
#sql = """SELECT alu_id, alu_nome, alu_uf, alu_cep, progresso_alfabetizacao FROM tb_students
|
|
|
|
| 21 |
|
| 22 |
conn = sqlite3.connect("afa-db.db")
|
| 23 |
|
| 24 |
+
sql_example = """SELECT alu_id, alu_nome, alu_uf, alu_cep, progresso_alfabetizacao FROM tb_students WHERE progresso_alfabetizacao >= 6 LIMIT 100"""
|
|
|
|
|
|
|
| 25 |
|
| 26 |
txt_example = """Qual um dos estudantes com maior nota no estado de SP?"""
|
| 27 |
|
|
|
|
| 49 |
df_std = df_std[:10]
|
| 50 |
return df_std, n_std
|
| 51 |
|
| 52 |
+
def execute_sql(sql):
|
| 53 |
+
data = None
|
| 54 |
+
try:
|
| 55 |
+
data = pd.read_sql(sql, conn)
|
| 56 |
+
except Exception as err:
|
| 57 |
+
st.error(err)
|
| 58 |
+
return data
|
| 59 |
+
|
| 60 |
st.info('Amostras de Dados:')
|
| 61 |
e1 = st.expander('Professores:', expanded=False)
|
| 62 |
with e1:
|
|
|
|
| 80 |
e4 = st.expander('Linguagem SQL:', expanded=False)
|
| 81 |
with e4:
|
| 82 |
sql = st.text_input("Digite uma instrução SQL válida:", sql_example)
|
| 83 |
+
if st.button("Processar Consulta"):
|
| 84 |
+
df = execute_sql(sql)
|
| 85 |
+
if df is not None:
|
| 86 |
+
st.dataframe(df)
|
| 87 |
|
| 88 |
e5 = st.expander('Linguagem Natural:', expanded=False)
|
| 89 |
with e5:
|
| 90 |
txt = st.text_input("Digite um texto de consulta válido:", txt_example)
|
| 91 |
+
if st.button("Processar Consulta"):
|
| 92 |
+
st.write("Em construção")
|
| 93 |
|
| 94 |
|
| 95 |
#sql = """SELECT alu_id, alu_nome, alu_uf, alu_cep, progresso_alfabetizacao FROM tb_students
|