Hi @Elijah_Nkuah - A few issues I think:
- You’re reusing the cursor across separate database calls.
- I’d run
execute()
onconn
, notc
.conn.execute()
returns ac
to fetch results. - Always commit after a logically complete set of update operations to make them atomic.
- Create the
conn
object as a singleton so it survives Streamlit reruns (can use session state or wrap it inst.cache
with a custom hash function forsqlite3.Connection
).
As a quick fix try:
conn = sqlite3.connect("usersdata.db", check_same_thread=False)
(Warning, your user signup implementation may trip up if two users try to create the same login credentials simultaneously, and your db scheme allows duplicate users. Hashing the password isn’t secure. It needs to be encrypted with a secret key.)
You could use my simple auth solution instead of dealing with all these issues yourself.
HTH,
Arvindra