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

2 years 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?

Closed

12 Replies

johnlins
HOBBYOP

2 years ago

N/A


2 years ago

you would want to store that file in a volume


2 years ago


johnlins
HOBBYOP

2 years ago

@Brody

Thanks, I just set one up!

Is this the intended use, because this and similar variations didn't seem to work:


            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")```


2 years ago

what's your mount path?


johnlins
HOBBYOP

2 years ago

Starting Container```


johnlins
HOBBYOP

2 years ago

1309406054165123154


2 years 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

2 years ago

1309407700291031082


johnlins
HOBBYOP

2 years ago

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


johnlins
HOBBYOP

2 years ago

It will print new_data but not "append..."


2 years ago

can you try to implement proper error handling


Welcome!

Sign in to your Railway account to join the conversation.

Loading...