File size: 1,101 Bytes
f493504
 
 
 
 
 
 
 
42104dc
 
d461ae7
30ae12e
139e8fc
 
42104dc
c45903e
 
f493504
9311bf4
f493504
 
 
d8a2c2b
 
4410b91
 
fb6df3b
d8a2c2b
c45903e
 
0492f04
1d31d8b
111174f
0492f04
f3536c1
3a757df
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
32
33
34
35
36
37
import streamlit as st
import os.path
import sqlite3

# Custom imports
from pages.utils import db_connect

def app():
    
    '''delete form_submit to run quiz maker on return to page'''
    if "form_submit" in st.session_state.keys():
        del st.session_state.form_submit
    if "form_upload" in st.session_state.keys():
        del st.session_state.form_upload
    
    st.markdown("## View Data")

    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    DATABASE = os.path.join(BASE_DIR, 'quiz_maker.db')

    c, conn = db_connect(DATABASE)

    size_query = "SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size()"
    
    c.execute(size_query)
    
    st.markdown(f'##### Database size: {int(c.fetchone()[0] / 1000)} KB')

    query = st.text_input("Query", placeholder="Type query here")

    if len(query) > 1:
        try:
            for idx, item in enumerate(c.execute(query)):
                st.write(f'{idx}: {item}')
        except Exception as e:
            st.write("Query failed. " + str(e).capitalize())