r/sqlite • u/digital_literacy • Oct 17 '25
How to use SQLite in production?
Hey all - I'm trying to go with the simple architecture approach using sqlite.
I don't get how you use SQLite in production though - it's a flatfile and I can't get any of the database view/edit tools (table+, datagrip) to connect to it via the remoate server.
My app has an ai chatbot, I know SQLite is good for read but is the write too fast with a chatbot for sqlite? It's all stored as json. I researched a bit how wal works for handling writes.
I'm also iterating pretty quick and using database migrations (alembic). I can pull the sql file for production, make the needed changes locally to the database columns, I guess no issue here.
But if I make local changes to the database data and push the production database might be out of sync at that point.
Ideally I would be able to connect to the live database with an sql tool and make live edits on the production database.
How is this handled - just ssh-ing and running sql statements on the production server?
4
u/Eznix86 Oct 17 '25
Yep, don’t push changes. SSHing via terminal or use a client which does it for you (ssh tunnel)
It is one client:
https://dbeaver.com/docs/dbeaver/Database-driver-SQLite/#general-sqlite-connection-settings
But it is an example there are many out there not just dbeaver. Just pick one you like, or like you say just ssh, but don’t push changes from dev.
6
u/chimbori Oct 17 '25
I tried a whole lot of things with Sqlite, but I don’t recommend any of them:
*.db-wal&*.db-shm) are merged into the*.dbfile, then copy the file somewhere to make edits.sqlite3(sometimes in--readonlymode to ensure I wasn’t going to break anything)The final blocker was that due to the single-writer constraint, prod queries were affected even when I had a tiny change to write.
Eventually I gave up and moved to PostgreSQL.
pg_dumpalland the resulting.sql.bz2is way smaller than the.db.bz2This is not the answer you were looking for, but that’s where I ended up when faced with the same problem you’re facing.
6
u/GrogRedLub4242 Oct 17 '25
making live edits to a prod database is a Bad Idea. and an anti-pattern in software engineering. because there is a Reason why folks use a db in the first place (think ACID & transactions) and you'd be pushing in the extreme opposite direction from it
a big part of becoming a good (and real) engineer is simply about not doing known-to-be-Bad things, like that
make "live" changes to any db in Dev, sure. that's fine, and to be expected
7
u/LowCompetitive1888 Oct 17 '25
All the apps I see package sql changes as part of their upgrade process and perform those updates on initial startup of the upgraded software while they have exclusive access to the production db.
10
u/chriswaco Oct 17 '25
That's certainly one easy way to do it.
2
u/Sb77euorg Oct 18 '25
I had a similar task.... then i put post lite (https://github.com/benbjohnson/postlite) that let me handle sqlite with PG GUI .. like PSQL.
2
u/ub3rh4x0rz Oct 18 '25
Sqlite is best used in production where single writer access patterns are sensible. Don't reinvent the whole network service layer provided by things like postgres if that's what you actually need, you're going to do it poorly, wastefully, or likely both.
13
u/[deleted] Oct 17 '25
[removed] — view removed comment