First, create a new resource to connect to your Postgres database. A resource represents a connection between Retool and your data source. It stores authentication and connection details so you can query the database in your apps.
To get started, log in to Retool and select the Resources tab. Click Create new and then select Postgres. Give your resource a name (e.g., Vendor Database), enter the host, port, and name of your database, and then select an authentication method.
Retool supports two methods of authenticating to a Postgres database:
- User and Password: Password-based authentication. Credentials are shared across users.
- AWS IAM authentication: AWS credential based authentication. You can provide AWS access keys or, if you are hosting Retool on AWS EC2, use the instance's underlying AWS IAM role. Credentials are shared across users.
For both authentication methods, you must add Retool's IP addresses to your database's allowlist. If you're using the cloud version of Retool, you can find the IP addresses on the Connect to a database page.
You can now select your newly-created PostgreSQL resource from the Select Resource dropdown when creating queries in your Retool apps. You can toggle between SQL mode for raw SQL statements or the GUI mode for structured writes.
You can display the results of PostgreSQL queries as with any other query in Retool:
Updated 10 days ago