How do I connect to sqlite on fly.io?
I followed the instructions on fly.io on how to setup a project using sqlite. I believe I did it all correctly. I've created a volume and an app and I've linked the volume to the app. Now I don't know how to connect to the sqlite db on there. On local I simply do
new Database('sqlite.db')
but I don't know what to use on fly.io. There are no docs on fly.io about this either, and I already asked on their forums.
Has anyone done this before? 🙂9 Replies
you do it exactly the same
read about LiteFS in their docs
I've gone into their litefs section but it keeps mentioning rails
there's a node example somewhere in the docs
also, the example we provided should have everything you need to use it
Hmm yeah I've found this section on LiteFS but it's just so confusing to me. It feels like they expect me to have more knowledge about LiteFS that I just don't have.
https://fly.io/docs/litefs/getting-started/#installing-litefs
For example this litefs.yml file
How does this correlate to the volume that I created? I named my volume
primenv_db
. Should I point to that instead of /litefs
?
And then the lease config. I only need 1 node that has write access. Do I still need this config? Where do I put it? I already have a lease config with type: 'static'.
And in the drizzle-orm docs I only see this
Where does sqlite.db
come from? How do I know what the name of the .db
file is on fly.io?
Sorry for the bombardment of questions. It's just very confusing 😓Yes, it is a bit confusing. The
fuse.dir
is the directory where you can put your DB files. So you can create the DB with any file name in that directory and it will be automatically synced using LiteFS.
The example I was referring to is a separate repo where we implemented the fly.io/LiteFS example specifically.GitHub
GitHub - drizzle-team/drizzle-flyio-litefs: Drizzle ORM Fly.io Lite...
Drizzle ORM Fly.io LiteFS example. Contribute to drizzle-team/drizzle-flyio-litefs development by creating an account on GitHub.
It's not linked in the README though, so I can't blame you for not finding it yourself
This example is a bit outdated in terms of the ORM API, but it should give you an idea about how to use it
Thanks I will check it out
I've updated my config but now the server is crashing.
I took these steps:
1. Removed all apps from my fly.io dashboard
2. Updated my fly.toml with this
3. Updated my dockerfile
Honestly, I'm not sure. Maybe you should ask around the fly.io community, since this is not really related to Drizzle I think.