Discord.py Railway json
lightdever
TRIALOP

a year ago

I use discord.py and use json file to save user informations but it doesn't work in railway how can I solve this issue?

Solved

31 Replies

lightdever
TRIALOP

a year ago

N/A


a year ago

You store data in a json file? That's so based I used to do that

Althouh I'd recommend just using a database, it's much easier that way. If you have to use a json file though then store it within a [volume ](), that way the data will persist between deployments

Anyway, what doesn't work about it?


lightdever
TRIALOP

a year ago

So it stores it in the volume but I think the bot.py can't modify the json files so when we restart it rollbacks


a year ago

If there was a permission issue regarding writing to the file then I'm sure python would've wrote an error

are you sure you have the volume mounted on the correct location?
if your app stores the json file in /data then you might have to mount the volume to /app/data


a year ago

(assuming you're using nixpacks)


lightdever
TRIALOP

a year ago

i'll try


lightdever
TRIALOP

a year ago

it wont work 😦


lightdever
TRIALOP

a year ago

BASE_DIR = os.path.dirname(os.path.abspath(__file__)) WORD_DATA_FILE = os.path.join(BASE_DIR, "word_data.json") BALANCE_DATA_FILE = os.path.join(BASE_DIR, "bankbalance.json") ATTENDANCE_DATA_FILE = os.path.join(BASE_DIR, "attendance.json") HISTORY_DATA_FILE = os.path.join(BASE_DIR, "history.json")


lightdever
TRIALOP

a year ago

Does this kind of don't work in railway?


lightdever
TRIALOP

a year ago

Is there another solution?


lightdever
TRIALOP

a year ago

Just a want to way to save informations


lightdever
TRIALOP

a year ago

If possible with json


a year ago

what's your current volume mount path?


lightdever
TRIALOP

a year ago

don't have any


lightdever
TRIALOP

a year ago

is volume for saving files like json?


a year ago

a volume is for saving any files


lightdever
TRIALOP

a year ago

ahh


lightdever
TRIALOP

a year ago

what path do i need to set my volume?


a year ago

fragly has previously covered that question


lightdever
TRIALOP

a year ago

ok


lightdever
TRIALOP

a year ago

1341289389325549600


lightdever
TRIALOP

a year ago

It would just load the files that is saved in github and don't save


lightdever
TRIALOP

a year ago

Volume is in /data


lightdever
TRIALOP

a year ago

BASEDIR = os.path.dirname(os.path.abspath("/data")) WORDDATAFILE = os.path.join(BASEDIR, "worddata.json") BALANCEDATAFILE = os.path.join(BASEDIR, "bankbalance.json")
ATTENDANCEDATAFILE = os.path.join(BASEDIR, "attendance.json") HISTORYDATAFILE = os.path.join(BASEDIR, "history.json")


a year ago

you would want to add logging to print those paths to make sure they are correct


lightdever
TRIALOP

a year ago

ok


a year ago

<:bruhdy:1330634189283917855>


lightdever
TRIALOP

a year ago

I'll figure it out with db because json is too old thank you for helping 😄


a year ago

@Fragly solve time


a year ago

Oh true, thank you!


a year ago

!s


Status changed to Solved dev about 1 year ago


Loading...