Hello, I’m having issues with my Streamlit app. I have created a SQLite3 connection like this:
import sqlite3
import streamlit as st
@st.cache_resource
def get_db_connection():
return sqlite3.connect("database.db", check_same_thread=False, uri=True)
conn = get_db_connection()
c = conn.cursor()
c.execute('''
CREATE TABLE IF NOT EXISTS users (
user_id TEXT PRIMARY KEY NOT NULL UNIQUE,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
)''')
conn.commit()
I can use the database in the Streamlit app with no any issues. However, when the app reboots, the DB gets erased along with all the table structures and data inside. The whole database.db file gets removed. I need to create it again, but it causes irreversible data loss. How can I find a solution to this?
Thanks.