Where is my data stored and how can I access it from outside my rails app ?

Hi,
I’m new to fly.io.
I’ve followed the tutorial to deploy a small Rails app with the default configuration and everything works smoothly.
I’ve started adding data to the database through the forms of the app but I can’t seem to understand where the data is actually stored and if there’s a way to access it from outside the app.
Any help would be much appreciated.

Thank you

The rails tutorial creates a Postgres database for you. You can run fly pg list to see your database, and you can log into it with fly pg connect -a <database-app-name>. You can read more about Postgres in our docs here.

1 Like

Thank you for your help.
My initial launch did create a Postgres db but my app was by default configured to use sqlite3 and as a result the pg database is not in use by the app.
I guess I should switch locally to pg setting up the fly pg database as the production db in my database.yml file and deploy again, is that right ?

If your Gemfile contains gem "pg" in it, and the following command returns a string starting with postgres: then you are configured to use Postgres:

fly ssh console -C 'printenv DATABASE_URL'
1 Like

Thank you very much !
I’ve just switched my local app to pg and I’m indeed getting the following
printenv DATABASE_URL
postgres://
How should I configure my local app to connect to it?

Hi @pszmidt! Unfortunately the DATABASE_URL string contains the credentials to access your database, so it would be wise to change it before you put any data into it!

I don’t have a guide at my fingertips for changing that, but this looks relevant: Error trying to (re)attach a database: "app already contains a secret named DATABASE_URL"

Fly Postgres · Fly Docs These docs should also help you get your app talking to Postgres, especially this doc

Thank you

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