i'm a new user i want to save the flows to the dat...
# best-practices
r
i'm a new user i want to save the flows to the database PostgreSQL, I added the connection and the prefect tables was added to my database, I have a record in table configuration , But the flows and the logs not inserted to my PostgreSQL database, i don’t know what i’m missing, can someone help me please?
1
a
Welcome, @Rabea Yousof! You don't need to store your flows to Postgres, we use the concept of storage for that. If you run everything locally, you don't even have to worry about storage. Check out this PDF for details on deployments and this repo this might be also good to get started https://medium.com/the-prefect-blog/scheduled-data-pipelines-in-5-minutes-with-prefect-and-github-actions-39a5e4ab03f4
r
Thank you, i need to apply this feature with PostgreSQL to keep the data on my database
a
what feature? what problem are you trying to solve?
r
i'm trying to save the the flows and tasks history and logs to PostgreSQL https://docs.prefect.io/concepts/database/#configuring-a-postgresql-database i applied the all steps, but when i run the flow the data not saved to the prefect tables in the DB
a
it happens by default, no need to do anything there, the history and logs are written to DB
if you instead mean task and flow run results, you can set:
Copy code
prefect config set PREFECT_RESULTS_PERSIST_BY_DEFAULT=true
this way all results will be by default persisted in your default storage location
z
It sounds like you’re trying to use the Postgres database backend instead of SQLIte? Did you resolve this?
You’ll want to use
prefect config set PREFECT_ORION_DATABASE_CONNECTION_URL="postgresql+asyncpg://..."
so that it applies to all your flows
@terrence Maybe the
export
in that tutorial should be a
prefect config set
?
👍 1
r
@Zanie Yes, i'm using Postgres as backend now with the local prefect and it's working very good. Can i use Postgres database backend or secondary database with prefect cloud?
z
Prefect Cloud has its own backing database. You can use profiles to switch between local/cloud if you want, but they wont share data.
👍 1
r
Hi @Zanie, can you help me with this error, I added the connection string and i started the Orion,
m
@Rabea Yousof @Zanie were you able to get this resolved. I recently switched from SQLite to Postgres and got that error. I am working to try and troubleshoot now.