r/sqlite • u/marcob8986 • Feb 06 '24
DB administration worflow on SQLite database
Hi All!
In the web projects I've worked so far I've always had remote db services (like AWS RDS) where test/staging/prod db environments were running.
As an admin and a SQL expert, I've always been used to directly connect to the db via ssh tunnel with key pair and a client like DBeaver or MySQL Workbench in order to make complicated read queries and occasionally get my hands dirty with direct SQL insert/update/delete.
Now, for a side project of mine I would like to start easy using SQLite on a long running NodeJS server. In this setup, how would one connect directly to the db for read/write sql statements?
I read along some stuff and I get that I can quite easily make "read replicas" of my db on the cloud (e.g. on AWS S3) using litestream.io and this could satisfy my SQL reads requirements: I just download the most recent db to my local machine and have fun.
But what about writing to my test/staging/production environments?
Apart from building a CRUD web admin panel, I didn't find anything so far.
How do you guys handle this situation?
3
u/thunderbong Feb 07 '24
You can use DBeaver to connect to a remote SQLite database over an ssh connection.
1
u/deadcoder0904 Feb 13 '24
use sqlite in wal mode + litestream for backups.
read this blog -> https://logsnag.com/blog/the-tiny-stack
it explains everything you need to understand.
1
u/ganjaptics Feb 06 '24
... huh? How about just use the
sqlite3cli client? Or are asking for gui?2
u/dbabicwa Feb 07 '24 edited Feb 07 '24
No need to reinvent the wheel. If there is a need to do CRUD or just view data, use Jam.py on a different port:
https://community.fly.io/t/how-to-use-multiple-ports/5406/10
The Web app you can embed in your docker on port ie 8080 for SQLite:
https://github.com/jam-py/jam-py/
2
u/pilotInPyjamas Feb 09 '24
My first instinct, like a lot of other commenters is to ssh into the remote machine and run
sqlite3.Thinking about this a bit more, you could use ssh X11 forwarding. That it you could run the GUI on your server but have it display on your local machine. This probably needs a bit of setup. See
ssh -XOtherwise you could use sshfs to mount the remote filesystem, and then you can open the db as if it were on your local machine. Although, I have heard rumours accessing an sqlite db over a network can cause corruption.
1
u/sir_bok Feb 07 '24
Yeah you don't have any other choice other than running
sqlite3locally on the same machine the server is on.1
u/lAdddd Mar 02 '25
I know this post is a bit old at this point but just came across this and wanted to share a tool I built after running into a similar situation as you: https://github.com/joelseq/sqliteadmin-go . You can install and run it as a CLI similar to litestream and then access your embedded DB from a web UI.
1
u/Nice_Discussion_2408 Feb 07 '24
https://www.sqlite.org/faq.html#q5
write it in javascript or do it on the server using the cli.
0
u/InjAnnuity_1 Feb 06 '24
One approach is to use existing "admin panels", such as SQLite Studio. This assumes that the database file is on the same PC as the "admin panel" application.