Robert Castagna commited on
Commit
8dbc465
1 Parent(s): bed2d7a

sqlite3 db upload

Browse files
Files changed (3) hide show
  1. app.py +25 -1
  2. fin_data_api.py +10 -9
  3. requirements.txt +2 -1
app.py CHANGED
@@ -1,4 +1,28 @@
1
  import streamlit as st
 
 
 
2
 
3
  x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import sqlite3
3
+ import pandas as pd
4
+ import streamlit as st
5
 
6
  x = st.slider('Select a value')
7
+ st.write(x, 'squared is', x * x)
8
+
9
+
10
+ conn = sqlite3.connect('fin_data.db')
11
+ c = conn.cursor()
12
+ c.execute("""
13
+ select * from test
14
+ """)
15
+
16
+ rows = c.fetchall()
17
+
18
+ # Extract column names from the cursor
19
+ column_names = [description[0] for description in c.description]
20
+
21
+ # Create a DataFrame
22
+ df = pd.DataFrame(rows, columns=column_names)
23
+
24
+ print(df)
25
+ st.dataframe(df)
26
+
27
+ conn.commit()
28
+ conn.close()
fin_data_api.py CHANGED
@@ -4,6 +4,7 @@ import json
4
  import requests
5
  import datetime
6
  import sqlite3
 
7
 
8
  with open('secrets.json') as f:
9
  content = json.load(f)
@@ -53,14 +54,14 @@ def sentiment_analysis(headline:str) -> str:
53
  #print(res_sentiment['data'][0].keys())
54
 
55
 
56
- # put data in database after figuring out what data we want to store
57
- conn = sqlite3.connect('fin_data.db')
58
- c = conn.cursor()
59
- c.execute("""
60
- select * from test
61
- """)
62
 
63
- print(c.fetchall())
64
 
65
- conn.commit()
66
- conn.close()
 
 
4
  import requests
5
  import datetime
6
  import sqlite3
7
+ import pandas as pd
8
 
9
  with open('secrets.json') as f:
10
  content = json.load(f)
 
54
  #print(res_sentiment['data'][0].keys())
55
 
56
 
57
+ # # put data in database after figuring out what data we want to store
58
+ # conn = sqlite3.connect('fin_data.db')
59
+ # c = conn.cursor()
60
+ # c.execute("""
61
+ # insert into test values (2, 'test value two')
62
+ # """)
63
 
 
64
 
65
+
66
+ # conn.commit()
67
+ # conn.close()
requirements.txt CHANGED
@@ -16,4 +16,5 @@ pathos
16
  transformers
17
  requests
18
  datetime
19
- pysqlite3 == 0.5.2
 
 
16
  transformers
17
  requests
18
  datetime
19
+ pysqlite3 == 0.5.2
20
+ streamlit