Your username and password didn't match. Please try again. SQLite not permanent storage?

Continuing the discussion from Using sqlite from persistent volume for Django application:

I followed a nice FLY-SQLite tutorial alongside a good Svelte-Django tutorial but still can’t login, even though the user and password are the same that I use for local access. I think the SQLite database from my local machine is not syncing with the remote volume that’s attached to my app. Any suggestions on troubleshooting? I’m using dj_database_url, and have my DATABASE_URL secret set through fly secrets set DATABASE_URL=sqlite:///db.sqlite3 It doesn’t seem as if I am doing this correctly. I’ve tried and retried and gone around in circles. I’m using a .env file but it only contains DEBUG=True I think my myapp/settings.py is messed up around the DATABASES part:

# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases

#DATABASES = {
#    "default": {
#        "ENGINE": "django.db.backends.sqlite3",
#        "NAME": BASE_DIR / "db.sqlite3",
#    }
#}
#DATABASES['default'] = dj_database_url.config(
#    default='sqlite:///db.sqlite3',
#    conn_max_age=600,
#    conn_health_checks=True,
#)
DATABASES = {
    'default': dj_database_url.config(
        default='sqlite:///db.sqlite3',
        conn_max_age=600,
        conn_health_checks=True,
    )
}
#DATABASES = {
#   "default": env.dj_db_url("DATABASE_URL", default="sqlite:///db.sqlite3"),
#}

Hi… It looks like you might perhaps have misread this piece of the tutorial (understandable!). The one there is instead sqlite:////data/db.sqlite3, with four slashes immediately after the colon and then the (crucial) data/ step in the path.

(That latter should correspond to destination under [mounts] in your fly.toml file.)

In general, the Fly.io platform doesn’t synch volumes. You’re expected to instead either start over from scratch in production (typical) or, more rarely, manually upload your initial database via SFTP.


Aside: I understand what that other tutorial is saying about the complexity of multiple machines, but having just a single one really is not recommended on Fly, :dragon:. In particular, this database could be lost in its entirety, unless you watch things very assiduously…

1 Like

From Questions / Help to Python

Added Django, sqlite, volumes

Thanks a million and more. I’m not necessarily seeing that I have persistent volume (or am I missing it?)

From the link to manually upload the db, I get this output:

fly sftp shell
» put local.db /tmp/local.db
put local.db -> /tmp/local.db: open local file: open local.db: no such file or directory
» put db.sqlite3 /tmp/db.sqlite3
131072 bytes written

$fly ssh console
Connecting to fdaa:a:56fd:a7b:1ab:1302:881e:2... complete
root@7811ed9f5e4378:/code# cd /data

root@7811ed9f5e4378:/data# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        464M     0  464M   0% /dev
none            7.8G   38M  7.4G   1% /
/dev/vdb        7.8G   38M  7.4G   1% /.fly-upper-layer
shm             484M     0  484M   0% /dev/shm
tmpfs           484M     0  484M   0% /sys/fs/cgroup
/dev/vdc        974M  184K  908M   1% /data

You’re good here, although admittedly that’s not obvious…

(The fact that /data appears in the final column is the main thing. That means that it’s a separate, distinguished part of the overall filesystem tree—which is exactly what a persistent volume is supposed to be!)

So I flew into the production code and created a superuser and now I can login – your comment really helped.

1 Like

Great, thanks for pointing that out. (I was focussing on the left column :roll_eyes:) One last thing, in the manual upload instructions, you wrote server.db. which is probably one of these:

root@7811ed9f5e4378:/data# ls
db.sqlite3  db.sqlite3-shm  db.sqlite3-wal  lost+found
root@7811ed9f5e4378:/data# 

and I would move that to old.db and then go into /tmp and move the one that I uploaded …

But I’m not going to do that since thanks to you I learned that I could create the superuser directly on the production database. Thanks once again!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.