# Postgres Command

We are now ready to use the plugin to query data from our database.

The Postgres Command is currently the only action available for connecting to a Postgres database. The workflow property editor requires you to specify the following fields:

* **Query Type:** Choose from the dropdown list of options
  * RAW (the only available option currently)
* **Query:** The query text to retrieve/modify the database.&#x20;
  * e.g. "SELECT \* FROM dbo.Customers"&#x20;
* **Data Type:** The custom Data Type field definition
  * *Note: This Data Type must be a custom Data Type defined by the Bubble SQL Connector and not a Bubble Database Data Type*&#x20;

An example select statement based on the customer definition we have been using:

<figure><img src="https://3429571269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRRqIJYs420fGe4ggAhXs%2Fuploads%2Fdd3oveEruh4QSqGGtEcB%2FScreenshot%202022-09-19%20at%205.39.23%20PM.png?alt=media&#x26;token=16b46905-dfa5-4f8f-b98f-7d8f4ba0c47d" alt=""><figcaption></figcaption></figure>

When you retrieve the results the action makes several properties available for use within further workflow steps. These properties are:

* **Data:** This property gives you access to the results data object.&#x20;
  * *Note: The Data Type of this property is the custom Data Type defined in the "Data Type" field specified in the SQL Command property editor.*
* **timer:** This property allows you to determine how long the query is taking to execute. This field is provided to help in debugging.
* **json:** This property contains the JSON results of the data type. This is convenient if you need to pass the data along to another API/workflow which requires JSON input.
* **meta:** If there is meta information returned by the query it will be available in this field. If the query returns no meta information then this field will be empty.
* **Completed:** This field will be "yes" when the query has completed and "no" while it is still running. This is convenient for loading pages/icons.

You can execute the Postgres Command on the "Page is Loaded" event or on a button click event or however works best in your application. Then set a custom state with the results and use them in your application.

<figure><img src="https://3429571269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRRqIJYs420fGe4ggAhXs%2Fuploads%2FKUyy3efXlQ18rgSXbS0L%2FScreenshot%202022-09-19%20at%205.44.11%20PM.png?alt=media&#x26;token=b79733e0-ff18-44fb-88ca-6fc8eb620b09" alt=""><figcaption></figcaption></figure>

Since we have defined the custom type you can use all of the field properties as you would with data coming directly out of the Bubble default database.

<figure><img src="https://3429571269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRRqIJYs420fGe4ggAhXs%2Fuploads%2FklT6QcFWN7Is8dGBawNl%2FScreenshot%202022-09-19%20at%206.03.49%20PM.png?alt=media&#x26;token=32d15004-cf53-47d1-a4e8-2081b3104b2a" alt=""><figcaption></figcaption></figure>
