Spaces:
Sleeping
Sleeping
| import sqlite3 | |
| import uuid | |
| import json | |
| import streamlit as st | |
| from utilities import ( | |
| load_local_css, | |
| set_header, | |
| load_authenticator, | |
| send_email, | |
| ) | |
| import streamlit_authenticator as stauth | |
| import yaml | |
| from yaml import SafeLoader | |
| # st.set_page_config(layout="wide") | |
| # load_local_css("styles.css") | |
| # set_header() | |
| # for k, v in st.session_state.items(): | |
| # if k not in ["logout", "login", "config"] and not k.startswith( | |
| # "FormSubmitter" | |
| # ): | |
| # st.session_state[k] = v | |
| # with open("config.yaml") as file: | |
| # config = yaml.load(file, Loader=SafeLoader) | |
| # st.session_state["config"] = config | |
| # authenticator = stauth.Authenticate( | |
| # config["credentials"], | |
| # config["cookie"]["name"], | |
| # config["cookie"]["key"], | |
| # config["cookie"]["expiry_days"], | |
| # config["preauthorized"], | |
| # ) | |
| # st.session_state["authenticator"] = authenticator | |
| # name, authentication_status, username = authenticator.login("Login", "main") | |
| # auth_status = st.session_state.get("authentication_status") | |
| # if auth_status == True: | |
| # authenticator.logout("Logout", "main") | |
| # is_state_initiaized = st.session_state.get("initialized", False) | |
| # if not is_state_initiaized: | |
| database_file = r'C:\Users\ManojP\Documents\Mastercard\Build\DB_Sample\DB\User.db' | |
| conn = sqlite3.connect(database_file) | |
| c = conn.cursor() | |
| #c.execute('DROP TABLE IF EXISTS users ') | |
| # c.execute('DROP TABLE IF EXISTS sessions ') | |
| # conn.commit() | |
| #output = c.fetchall() | |
| #st.write(output) | |
| c.execute('''CREATE TABLE IF NOT EXISTS users | |
| (user_id INTEGER PRIMARY KEY, | |
| username TEXT, | |
| email TEXT, | |
| user_type TEXT )''') | |
| c.execute('''CREATE TABLE IF NOT EXISTS sessions | |
| (user_id INTEGER, | |
| owner TEXT, | |
| session_id INTEGER, | |
| session_name TEXT, | |
| status TEXT, | |
| created_time TIMESTAMP, | |
| updated_time TIMESTAMP, | |
| allowed_users TEXT)''') | |
| #c.execute("DELETE FROM sessions") | |
| user_id = str(uuid.uuid4()) | |
| # c.executemany("INSERT INTO users (username, email,user_type) VALUES (?, ?,?)", | |
| # [("Geetha Krishna", "[email protected]","technical"), | |
| # ("Samkeet Sangai", "[email protected]","technical"), | |
| # ('Manoj P','[email protected]',"technical"), | |
| # ('Srishti Verma','[email protected]',"technical"), | |
| # ('Ismail mohammed',"[email protected]","technical"), | |
| # ('Sharon Sheng','[email protected]',"technical"), | |
| # ('Ioannis Papadopoulos','[email protected]',"business"), | |
| # ('Herman Kwong',"[email protected]",'technical'), | |
| # ]) | |
| conn.commit() | |