This documentation describes the integration of MindsDB with PostgreSQL, a powerful, open-source, object-relational database system. The integration allows MindsDB to access data stored in the PostgreSQL database and enhance PostgreSQL with AI capabilities.
Before proceeding, ensure the following prerequisites are met:
pip install mindsdb[postgres]
.Establish a connection to your PostgreSQL database from MindsDB by executing the following SQL command:
Required connection parameters include the following:
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.Optional connection parameters include the following:
schema
: The database schema to use. Default is public.sslmode
: The SSL mode for the connection.Retrieve data from a specified table by providing the integration name, schema, and table name:
Run PostgreSQL-native queries directly on the connected PostgreSQL database:
The above examples utilize psql_datasource
as the datasource name, which is defined in the CREATE DATABASE
command.
Next Steps
Check out the House Sales Forecasting tutorial, which uses the data from PostgreSQL connection to MindsDB.
Database Connection Error
SQL statement cannot be parsed by mindsdb_sql