How to set password on sqlite database with node-sqlite3
The title says it all
15 Replies
what are you trying to accomplish by setting a password?
Shouldn't you do it?
username / password is important if you access things through a network connection, but sqlite is a local file on disk
you need to make sure your server is secure, that access to your files is restricted to only those who should have access, but generally you don't set passwords on sqlite
there's some encryption options, but by that point it might be better to just switch to mysql or postgres
So the server is what I should be making sure is secured, correct?
yeah
don't put your sqlite file anywhere web accessible is step 1 in that
How do I do it?
just don't keep it in your assets folder, probably
not sure what your project looks like
This might sound stupid, but should I gitignore the db?
probably yes, as long as you have a way to set it up in git
like, your initialization script should be in git, the .sqlite file probably shouldn't be
Initialization script, being the script I used to make tables?
yes
your database structure is as much a part of your application as the Javascript, so if you lose that structure and the ability to recreate it, your application won't work
your git repo should contain everything you need to get your application to work, but no instance data (as in data that would vary depending on where you installed your app)
you could theoretically make a bare version of your db and commit that, and then copy that when you install your app, but it's better practice to use initialization scripts
Assuming I pushed my db with data to a public repo. Am I in trouble?
depends on your data 🤷
Yeah, haha. I knew the answer
Thanks Jochem. Im glad I asked here. Godbless you 🙂
no worries, glad to help!