I’m working on a little project to automate the setup of a board game to share with my nerdy board game friends while also giving me experience with Streamlit. I have the data in two tables in a SQLite database that I’ve uploaded to my Github. There is nothing secret or sensitive in this database whatsoever. For some reason, I’m getting an error on my deployed app:
OperationalError: no such table: games
This leads me to believe the app is accessing the database, but not finding the tables. My secrets.toml are: [sqlite] database = "gamessqlite.db"
There are two tables: games and components.
I get the same error when running it locally, however, when I adjust the db_path in my code from st.secrets['sqlite'] to the absolute path of the database on my computer, I can run the app just fine. Am I setting my secrets up incorrectly? There was no guide and very little found in my searches for deploying a streamlit app using a SQLite database. Does anybody know what might be happening? I really appreciate the help!
Alright, I figured out the problem on the local side. I was using a relative path to my local database. As such, in my command prompt, I changed directory to the directory that actually had the database, and boom, it loaded just fine. I’m sure I could have added an absolute path to secrets.toml and it would have worked all the same.
Now that I figured that out, I’m still running into an issue with my shared app. How do I reference the database in Github. Is it even possible? I tried copying the link to the file in Github and put that in as my database in my secrets. That didn’t work.
So, here’s the trick for anybody else looking to use a SQLite database on Github:
Pay attention to your console. When I rebooted my app once more, I watched it spin up in the console. I noticed it cloned the repository over to Streamlit (it’s not just referencing the code from Github). Where it said main module, I got the idea that I could use that as my relative path. That did the trick.
Again, if you’re wanting to use a SQLite database that you host on your Github, your secrets should look something like this: [sqlite] path/to/streamlit-cloned-repository/sqlite.db
I have no problem sharing my secrets in this case. Mine are: [sqlite] Boardgames/auto-setup/gamessqlite.db
I pondered this a little more after I got it working. The reason the first secrets didn’t work is because my app isn’t in the root of my Github repo. My repo is game-projects. If my database was in there, just using the database name is sufficient. Because the app (and database) is actually two folders deep from the repo (game-projects/Boardgames/auto-setup/), I needed more to the path.
So if you wanted to, instead of “game-projects/Boardgames/auto-setup/” you could have “game-projects/Boardgames/auto-setup/Modules/” and store Functions in the Secret Managment? What are your thoughts? This is what I would like to do.
Pulling from an additional /Modules is fine if you want to organize it a little better, but not necessary since it’s still publicly accessible from your repo. Functions generally aren’t secret as where databases and their credentials generally are.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.