This data source integration is thread-safe, utilizing a connection pool where each thread is assigned its own connection. When handling requests in parallel, threads retrieve connections from the pool as needed.
Prerequisites
Before proceeding, ensure the following prerequisites are met:- Install MindsDB locally via Docker or Docker Desktop.
- To connect PostgreSQL to MindsDB, install the required dependencies following this instruction.
Connection
Establish a connection to your PostgreSQL database from MindsDB by executing the following SQL command:user
: The username for the PostgreSQL database.password
: The password for the PostgreSQL database.host
: The hostname, IP address, or URL of the PostgreSQL server.port
: The port number for connecting to the PostgreSQL server.database
: The name of the PostgreSQL database to connect to.
schema
: The database schema to use. Default is public.sslmode
: The SSL mode for the connection.
Usage
The following usage examples utilize the connection to PostgreSQL made via theCREATE DATABASE
statement and named postgresql_conn
.
Retrieve data from a specified table by providing the integration name, schema, and table name:
Next StepsFollow this tutorial to see more use case examples.
Troubleshooting
Database Connection Error
- Symptoms: Failure to connect MindsDB with the PostgreSQL database.
- Checklist:
- Make sure the PostgreSQL server is active.
- Confirm that host, port, user, schema, and password are correct. Try a direct PostgreSQL connection.
- Ensure a stable network between MindsDB and PostgreSQL.
SQL statement cannot be parsed by mindsdb_sql
- Symptoms: SQL queries failing or not recognizing table names containing spaces or special characters.
- Checklist:
- Ensure table names with spaces or special characters are enclosed in backticks.
- Examples:
- Incorrect: SELECT * FROM integration.travel data
- Incorrect: SELECT * FROM integration.‘travel data’
- Correct: SELECT * FROM integration.`travel data`