sql database
iskon222222222222222
TRIALOP

a year ago

I'm using sqlite3. The data is saved successfully, but if the server is restarted, the db file is deleted. How can I prevent the database from being deleted? I'm using the free plan

7 Replies

brody
EMPLOYEE

a year ago

You are storing the database in temporary storage, you need to be using persistent storage.

https://docs.railway.app/guides/volumes


iskon222222222222222
TRIALOP

a year ago

in volumes settings /app/data/db

my code:

folder_path = '/data/db'

if not os.path.exists(folder_path):
    os.makedirs(folder_path)

db_path = os.path.join(folder_path, 'users.db')
conn = sqlite3.connect(db_path)

cursor = conn.cursor()

but my database is not working. Is this path correct?


iskon222222222222222
TRIALOP

a year ago

i tried like this

folder_path = '/app/data/db'

if not os.path.exists(folder_path):
    os.makedirs(folder_path)

db_path = os.path.join(folder_path, 'users.db')
conn = sqlite3.connect(db_path)

cursor = conn.cursor()

but this is also not working


iskon222222222222222
TRIALOP

a year ago

Help please


brody
EMPLOYEE

a year ago

Please read the guide, your path or mount point is incorrect.


iskon222222222222222
TRIALOP

a year ago

Can I connect to the main directory by FTP?


brody
EMPLOYEE

a year ago


Loading...