PostgreSQL Integration logo

PostgreSQL Integration

Connect your PostgreSQL database to Datapad and query your data using natural language instead of SQL.

Database5 min setupSSL Encrypted

Prerequisites

  • PostgreSQL Database - A running PostgreSQL instance (version 12 or higher) with your data
  • Database Credentials - Host, port, database name, username, and password with read access
  • Network Access - Database should be accessible from the internet or through VPN/SSH tunnel
  • SSL Certificate - SSL encryption for secure data transmission
  • Connection Methods

    Choose the connection method that best fits your security requirements and infrastructure setup.

    Database Connection Form

    Connect directly using your database credentials with SSL encryption.

    Connection String

    Use a PostgreSQL connection string with SSL encryption.

    SSH Tunnel

    Connect through an SSH tunnel for maximum security.

    Connection Guide

    Step 1: Access PostgreSQL Integration

    Navigate to Integrations in Datapad and select PostgreSQL:

    PostgreSQL connect screen on Datapad UI

    Step 2: Fill Connection String

    Enter your PostgreSQL database connection string:

    PostgreSQL connection string form in Datapad

    Required Fields:

    • Connection Name
    • Connection String
    • Database Schema
    The PostgreSQL connection string format is: postgresql://USERNAME:PASSWORD@HOST:PORT/DATABASE_NAME

    Step 3: Fill Connection Details

    Enter your PostgreSQL database connection details:

    PostgreSQL connection form in Datapad

    Required Fields:

    • Database Host
    • Port (default: 5432)
    • Database Name
    • Username
    • Password
    • SSL Mode

    Create Read-Only User (Recommended)

    For security, create a dedicated user with read-only permissions:

    -- Create a new user for Datapad
    CREATE USER datapad_readonly WITH PASSWORD 'secure_password';
    
    -- Grant connect permission to the database
    GRANT CONNECT ON DATABASE your_database TO datapad_readonly;
    
    -- Connect to your database and grant schema usage
    \c your_database;
    GRANT USAGE ON SCHEMA public TO datapad_readonly;
    
    -- Grant select permissions on all tables
    GRANT SELECT ON ALL TABLES IN SCHEMA public TO datapad_readonly;
    
    -- Grant select permissions on future tables
    ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO datapad_readonly;
    
  • Replace your_database with your actual database name and choose a strong password for the datapad_readonly user.
  • Example Queries

    Here are some example questions you can ask once your PostgreSQL data is connected:

    "Show me the top 10 customers by revenue this month"
    "What's the average order value by customer segment?"
    "How many new users signed up each day this week?"
    "Which products have the highest profit margin?"
    "Show me monthly revenue growth for the last year"
    "What's our customer retention rate by cohort?"

    💬 Natural Language Tips

  • Be specific about time periods ("last 30 days", "this month vs last month")
  • Include table names when possible ("orders table", "users table")
  • Ask for comparisons to get more insights ("compare X vs Y")
  • Use business terms that align with your data schema
  • Behind the Scenes

    Datapad automatically converts your natural language questions into optimized PostgreSQL queries. You can always view the generated SQL to learn and verify the results, including PostgreSQL-specific features like JSONB queries and advanced analytics functions.

    Troubleshooting

    Connection timeout

    If the connection times out:

    • Check firewall settings and whitelist Datapad IPs
    • Verify the host and port are correct
    • Ensure PostgreSQL is accepting connections
    • Test connectivity from your network

    Authentication failed

    If authentication fails:

    • Verify username and password are correct
    • Check if the user has access to the database
    • Ensure user can connect from external hosts
    • Try connecting with the same credentials using psql client

    SSL connection issues

    If SSL connection fails:

    • Verify SSL is enabled on your PostgreSQL server
    • Check if you have valid SSL certificates
    • Try different SSL modes (require, prefer, disable)
    • Contact support for help with certificate issues
    Need Help?
    Our team is here to help you set up your integrations successfully