Skip to main content

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

FieldDescriptionExample
HostDatabase server addressdb.example.com or 192.168.1.100
PortPostgreSQL port5432 (default)
DatabaseDatabase nameanalytics
UsernameDatabase userreadonly_user
PasswordUser password••••••••

Step-by-Step Setup

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.conf to 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

  1. Go to Connections in 42Cells
  2. Click New ConnectionPostgreSQL
  3. Enter your connection details
  4. Click Test Connection
  5. 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_addresses in postgresql.conf includes the server IP or *

Authentication Failed

  • Verify username and password
  • Check pg_hba.conf authentication method (should be md5 or scram-sha-256)
  • Ensure the user has CONNECT privilege 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