PostgreSQL Setup
Connect your PostgreSQL database to 42Cells for AI-powered analysis.
Prerequisites
- PostgreSQL 12 or higher
- Network access from 42Cells to your database
- A database user with read permissions
Connection Details
| Field | Description | Example |
|---|---|---|
| Host | Database server address | db.example.com or 192.168.1.100 |
| Port | PostgreSQL port | 5432 (default) |
| Database | Database name | analytics |
| Username | Database user | readonly_user |
| Password | User password | •••••••• |
Step-by-Step Setup
1. Create a Read-Only User (Recommended)
For security, create a dedicated read-only user for 42Cells:
-- Create the user
CREATE USER datacells_reader WITH PASSWORD 'your_secure_password';
-- Grant connect permission
GRANT CONNECT ON DATABASE your_database TO datacells_reader;
-- Grant schema usage
GRANT USAGE ON SCHEMA public TO datacells_reader;
-- Grant read access to all tables
GRANT SELECT ON ALL TABLES IN SCHEMA public TO datacells_reader;
-- Grant read access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT ON TABLES TO datacells_reader;
2. Configure Network Access
Ensure your PostgreSQL server accepts connections from 42Cells:
For cloud-hosted databases (AWS RDS, Google Cloud SQL, etc.):
- Add 42Cells IP addresses to your security group or authorized networks
- Contact support for our current IP ranges
For self-hosted databases:
- Update
pg_hba.confto allow connections from 42Cells IPs - Ensure your firewall allows inbound connections on port 5432
3. SSL Configuration
We recommend enabling SSL for secure connections:
-- Check if SSL is enabled
SHOW ssl;
In 42Cells connection settings, enable SSL Mode if your server requires it.
4. Test the Connection
- Go to Connections in 42Cells
- Click New Connection → PostgreSQL
- Enter your connection details
- Click Test Connection
- If successful, click Save
Common Issues
Connection Refused
- Verify PostgreSQL is running:
sudo systemctl status postgresql - Check the port is correct (default: 5432)
- Ensure
listen_addressesinpostgresql.confincludes the server IP or*
Authentication Failed
- Verify username and password
- Check
pg_hba.confauthentication method (should bemd5orscram-sha-256) - Ensure the user has
CONNECTprivilege on the database
SSL Required
If you see SSL errors, enable SSL in the connection settings. For self-signed certificates, you may need to set SSL mode to "require" rather than "verify-full".
Permission Denied
Ensure the user has SELECT privileges:
-- Check current privileges
SELECT grantee, privilege_type
FROM information_schema.role_table_grants
WHERE grantee = 'datacells_reader';
Performance Tips
- Use connection pooling if making frequent queries
- Consider creating read replicas for heavy analytics workloads
- Index columns frequently used in WHERE clauses and JOINs