Can I host a single jsonl file that my project writes to via python?
johnlins
HOBBYOP

a year ago

I have a python project being hosted on railway, I would love to be able to, from python, write to the jsonl file from python and for that file to persist accross builds.

Is that possible or do I need to spin up a whole MongoDB server just for 1 files?

12 Replies

johnlins
HOBBYOP

a year ago

N/A


a year ago

you would want to store that file in a volume


a year ago


johnlins
HOBBYOP

a year ago

@Brody
Thanks, I just set one up!
Is this the intended use, because this and similar variations didn't seem to work:
``` mountpath = os.getenv("RAILWAYVOLUMEMOUNTPATH")

        data_folder = os.path.join(mount_path, "data")
        os.makedirs(data_folder, exist_ok=True)

        file_path = os.path.join(data_folder, "data_signedin.jsonl")

        new_data = {
          #...data...
        }
        print(new_data)

        with open(file_path, "a") as file:
            file.write(json.dumps(new_data) + "\n")```

a year ago

what's your mount path?


johnlins
HOBBYOP

a year ago

Mounting volume on: /var/lib/containers/railwayapp/bind-mounts/f8243c2e-e45c-471d-8d65-718db8175ddb/vol_uejr9ska7cudz3d4 Starting Container


johnlins
HOBBYOP

a year ago

1309406054165123000


a year ago

so from your code it looks like you'll be storing data in /app/data/data

strange path, but it seems fine logically, what is the actual issue?


johnlins
HOBBYOP

a year ago

1309407700291031000


johnlins
HOBBYOP

a year ago

In the actual code, it will not print the message below


johnlins
HOBBYOP

a year ago

It will print new_data but not "append…"


a year ago

can you try to implement proper error handling


Loading...