-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlitExamples.py
More file actions
41 lines (34 loc) · 1 KB
/
streamlitExamples.py
File metadata and controls
41 lines (34 loc) · 1 KB
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
38
39
40
41
import streamlit as st
from sqlalchemy.orm import sessionmaker
from project_orm import UserInput,Prediction
from sqlalchemy import create_engine
# from sqlalchemy import bind,sess
engine=create_engine('sqlite:///project_db.sqlite3')
Session =sessionmaker(bind=engine)
sess=Session()
st.title('I am Using Database with SqlAlchemy Here')
area =st.number_input('Enter house area in sqft',
max_value=10000,
min_value=100,
value=500
)
rooms =st.number_input('enter no of rooms',max_value=500,
min_value=0,
value=1)
age=st.number_input('age of house',
max_value=500,
min_value=0,
value=1)
location=st.text_area('Enter location address')
submit =st.button('make prediction')
if submit and location:
try:
entry =UserInput(house_area=area,
no_of_rooms=rooms,
age=age,
location=location)
sess.add(entry)
sess.commit()
st.success("data added to Database")
except Exception as e:
st.error(f"some error occur : {e} ")