The Database Query action allows you to execute SQL queries on the hosted Postgres database that comes with Fastgen. You can write SQL queries directly in the action, and the result of the query will be returned as a JSON object. This action is useful to retrieve, manipulate, and interact with your data from the database and using it in your endpoints or workflows.
The SQL query can include SELECT, INSERT, UPDATE, DELETE, or any other valid SQL statement supported by PostgreSQL.
The DB query action also works if you have connected your own External DB
Output
The output of the DB query action which will be accessible under{{$action['my-step']}} will have two properties,
{{$action['my-step'].Error}}
{{$action['my-step'].Result}}
Example
Let’s a assume we have a table calledorders which contains
customer_name,product_name,order_dateandstate
In the example above we access the result of the query with
Test Query
In the SQL editor you are able to test your statements withTest Query. If we test our query from the example above we receive the following:
The test result of SQL queries like Select will be displayed directly in the action as shown in the picture above. If you test statements which will modify the database like Insert or Update the result will only show if correct SQL syntax has been applied, the test queries to not modify the database.
For SQL statements with incorrect syntax, you will receive Invalid SQL: ERROR while testing.
SQL Copilot
The SQL editor includes a SQL Copilot which will assist you in creating your desired SQL statements:
After prompting the Copilot it will return SQL queries which you can copy, add to query or replace query.

