Querying Postgres

The following document assumes that you understand the basics of connecting to databases on Appsmith. If not, please go over them before reading further.

PostgreSQL databases can be queried using the standard SQL syntax. All postgres queries return an array of objects where each object is a row returned by the query and each property in the object is a column. Appsmith provides template queries to help with the syntax

Click to expand

Taking Inputs from Widgets

Queries can take inputs from widgets using the mustache syntax inside the query {{ searchInput.text }} where searchInput is the name of the widget and text is the property of the widget.

Don't forget to wrap your params with single quotes

select * from users where name = '{{nameInput.text}}'
Click to expand

Displaying Query Data

Query data can be displayed in a table or chart using the mustache syntax {{ queryName.data }} . You can read more about displaying query data below

The widgets are automatically refreshed when the data is changed