<@ULVA73B9P> How do i set up Prefect with Postgres...
# ask-marvin
c
@Marvin How do i set up Prefect with Postgresql without using Docker?
m
To set up Prefect with PostgreSQL without using Docker, you can follow these steps: 1. Install PostgreSQL: Make sure you have PostgreSQL installed on your system. You can install it using the official PostgreSQL downloads for your operating system. 2. Create a Database: Create a PostgreSQL database that Prefect will use. The default database name expected by Prefect is
prefect
. 3. Configuring Prefect to use PostgreSQL: - Set the
PREFECT_API_DATABASE_CONNECTION_URL
environment variable with your PostgreSQL connection details. Here's an example format for the environment variable:
Copy code
export PREFECT_API_DATABASE_CONNECTION_URL="postgresql+asyncpg://<USERNAME>:<PASSWORD>@<HOST>:<PORT>/<DATABASE>"
Replace
<USERNAME>
,
<PASSWORD>
,
<HOST>
,
<PORT>
, and
<DATABASE>
with your own PostgreSQL credentials and details. Here's a provided example assuming standard credentials and local PostgreSQL setup:
Copy code
export PREFECT_API_DATABASE_CONNECTION_URL="<postgresql+asyncpg://postgres:yourTopSecretPassword@localhost:5432/prefect>"
Make sure to replace
yourTopSecretPassword
with the actual password for your
postgres
user. For more details, you can refer to the Prefect documentation on hosting. Remember that the
postgresql+asyncpg
scheme is for asynchronous communication with PostgreSQL, which Prefect supports. If you're using synchronous libraries or tools that expect a synchronous connection, you would use a different URL scheme, like
postgresql://
. Keep in mind that if you choose to use PostgreSQL, you should also ensure you have the
pg_trgm
extension installed and enabled in your PostgreSQL instance, as Prefect uses this extension.