Allob commited on
Commit
ef2bb17
·
1 Parent(s): 8e8debc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Create the SQL connection to pets_db as specified in your secrets file.
4
+ conn = st.experimental_connection("sqlite:///data.db", type='sql')
5
+
6
+ # Insert some data with conn.session.
7
+ with conn.session as s:
8
+ s.execute('CREATE TABLE IF NOT EXISTS mytable (name TEXT, data TEXT);')
9
+ s.execute('DELETE FROM mytable;')
10
+ data_records = {'a': 'b', 'c': 'd', 'e': 'f'}
11
+ for k in data_records:
12
+ s.execute(
13
+ 'INSERT INTO mytable (name, data) VALUES (:name, :data);',
14
+ params=dict(name=k, data=data_records[k])
15
+ )
16
+ s.commit()
17
+
18
+ # Query and display the data you inserted
19
+ loaded_data = conn.query('select * from mytable')
20
+ st.dataframe(loaded_data)