docs/versioned_docs/version-3.0.0-LTS/data-sources/postgresql.md
ToolJet has the capability to connect to PostgreSQL databases for data retrieval and modification.
<div style={{paddingTop:'24px'}}>To establish a connection with the PostgreSQL data source, you can either click on the + Add new Data source button located on the query panel or navigate to the Data Sources page from the ToolJet dashboard and choose PostgreSQL as the data source.
ToolJet offers two connection types to connect to your PostgreSQL database:
To connect to PostgreSQL using Manual connection parameters, select Manual connection as the connection type and provide the following details:
To connect to PostgreSQL using a connection string, select Connection String as the connection type and provide the following details:
Note: We recommend creating a new PostgreSQL database user to have control over ToolJet's access levels.
:::info Please make sure the Host/IP of the database is accessible from your VPC if you have self-hosted ToolJet. If you are using ToolJet cloud, please whitelist our IP. :::
</div> <div style={{paddingTop:'24px'}}>To execute SQL queries, select the SQL mode from the dropdown and enter your query in the editor.
ToolJet offers support for parameterized SQL queries, which enhance security by preventing SQL injection and allow for dynamic query construction. To implement parameterized queries:
:parameter_name as placeholders in your SQL query where you want to insert parameters.{{ }} notation.Query: SELECT * FROM users WHERE username = :username
SQL Parameters:
Key: username
Value: oliver // or {{ components.username.value }}
You can set the timeout duration for SQL queries by adding the PLUGINS_SQL_DB_STATEMENT_TIMEOUT variable to the environment configuration file. By default, it is set to 120,000 ms.
Choose the GUI mode from the dropdown and select the operation Bulk update using primary key. Provide the Table name and the Primary key column name. Then, in the editor, input the records as an array of objects.
[
{
"customer_id": 1,
"country": "India"
},
{
"customer_id": 2,
"country": "USA"
}
]
:::tip