LeveredDocs

Postgres

Connect a PostgreSQL database to Levered.

What you need

ItemDescription
Connection stringpostgresql://user:password@host:5432/database for a user with read access.
SchemaThe schema that contains the exposures and rewards tables. The default is public.
CREATE ROLE levered_reader WITH LOGIN PASSWORD 'a-strong-password';
GRANT CONNECT ON DATABASE analytics TO levered_reader;
GRANT USAGE ON SCHEMA public TO levered_reader;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO levered_reader;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO levered_reader;

Connect via the dashboard

The dashboard requires an existing exposures table and rewards table before it saves the connection. Create the tables first (Create the table).

  1. Click Warehouse in the Levered dashboard sidebar.
  2. Click PostgreSQL.
  3. Enter the Connection String and Schema, then click Next.
  4. Select the Exposures table and the Rewards table.
  5. Click Save Connection.
  6. Click Test connection on the connection card to verify that Levered can reach the database.

Troubleshooting

Connection test fails

  • Check that the PostgreSQL server is accessible from the internet. If you use allowlisting, check that it is accessible from Levered's IP range.
  • Check that the hostname, the port and the credentials are correct.
  • Check that the user has CONNECT on the database and USAGE on the schema.

Permission errors at training time

Levered runs SQL queries during model training. If training fails with a permission error, check that the PostgreSQL user has SELECT access to the tables that the metric queries reference.

Next step

Set up the data pipeline to log exposures and rewards into the tables that Levered reads during training.