PostgreSQL Integration
Connect to PostgreSQL databases and sync table data to your knowledge base. Ideal for product catalogs, CRM data, and structured content.
How It Works
The PostgreSQL connector reads data from your database tables and converts rows into searchable text documents. Each row becomes a document that your bot can reference when answering questions.
- Automatically discovers tables and columns
- Extracts text from text-like columns (VARCHAR, TEXT, etc.)
- Supports selective table and column sync
- Enables incremental sync via timestamp columns
Read-Only Access
RAG Chats only reads data from your database. We never modify, insert, or delete any records.
Connecting PostgreSQL
Add Database Source
From Knowledge Base, click + Add Source → PostgreSQL.
Enter Connection Details
Provide your database connection information:
- Host: Database server address
- Port: Usually 5432
- Database: Database name
- Username: Database user
- Password: User password
Configure SSL (Recommended)
For production databases, enable SSL:
- prefer: Use SSL if available (default)
- require: Always use SSL
- verify-full: SSL with certificate verification
Select Tables
After connecting, select which tables to sync. You can sync all tables or choose specific ones.
Configure Columns (Optional)
By default, all text-like columns are indexed. You can customize which columns to include for each table.
Start Sync
Click Connect to begin syncing. Large tables are processed in batches.
Connection Settings
Hoststringdefault: localhostDatabase server hostname or IP address
Portintegerdefault: 5432PostgreSQL server port
Databasestringdefault: requiredName of the database to connect to
Usernamestringdefault: requiredDatabase user with read access
Passwordstringdefault: requiredUser password (stored encrypted)
Schemastringdefault: publicDatabase schema to sync from
SSL Modestringdefault: preferSSL connection mode: disable, allow, prefer, require, verify-ca, verify-full
Sync Settings
Tablesarraydefault: all tablesSpecific tables to sync (empty = all)
Text columnsobjectdefault: auto-detectColumns to index per table
Timestamp columnstringdefault: noneColumn for incremental sync (e.g., updated_at)
Batch sizeintegerdefault: 1000Rows per batch (100-10,000)
Auto-Detected Column Types
By default, these column types are automatically indexed as searchable text:
TEXTVARCHAR/CHARACTER VARYINGCHAR/CHARACTER
Numeric, date, and binary columns are included in metadata but not in the searchable text by default.
Example: Row to Document
A database row like this:
SELECT * FROM products WHERE id = 1;
-- id: 1
-- name: 500">class="text-green-500">"Wireless Headphones"
-- description: 500">class="text-green-500">"High-quality Bluetooth headphones with noise cancellation"
-- category: 500">class="text-green-500">"Electronics"
-- price: 149.99Becomes a searchable document:
Table: products
name: Wireless Headphones
description: High-quality Bluetooth headphones with noise cancellation
category: ElectronicsIncremental Sync
For tables with a timestamp column (like updated_at), you can enable incremental sync:
- Only new or modified rows are synced on subsequent runs
- Dramatically reduces sync time for large tables
- The timestamp of the last sync is stored automatically
Timestamp Column
Use a column that updates whenever the row changes. Common names: updated_at, modified_at, last_modified.
Security Best Practices
- Create a read-only user: Never use admin credentials
- Limit table access: Grant SELECT only on needed tables
- Use SSL: Always enable SSL for production databases
- IP allowlisting: Restrict database access to RAG Chats IPs
- Exclude sensitive data: Don't sync tables with PII or secrets
Example: Creating a Read-Only User
-- Create a dedicated user 500">for RAG Chats
CREATE USER ragchats_reader WITH PASSWORD 500">class="text-green-500">'secure_password';
-- Grant read-only access to specific tables
GRANT CONNECT ON DATABASE mydb TO ragchats_reader;
GRANT USAGE ON SCHEMA public TO ragchats_reader;
GRANT SELECT ON products, articles, faqs TO ragchats_reader;
-- Or grant access to all tables in a schema
GRANT SELECT ON ALL TABLES IN SCHEMA public TO ragchats_reader;Troubleshooting
Connection failed
- Verify host, port, database name, and credentials
- Check if the database server allows remote connections
- Ensure firewall rules allow the connection
- Verify SSL settings match server requirements
Permission denied
- Verify the user has SELECT permission on the tables
- Check schema permissions (USAGE on schema)
- Ensure the user can connect to the database
No data synced
- Verify tables contain text columns
- Check if tables are empty
- Ensure selected tables exist in the specified schema
Sync is slow
- Reduce the number of tables being synced
- Use incremental sync with a timestamp column
- Increase batch size for faster processing
- Consider indexing your timestamp column
Removing the Integration
- In RAG Chats, delete the PostgreSQL data source
- Optionally, revoke the database user's permissions or delete the user

