PostgreSQL Connections
TablePro provides full support for PostgreSQL 12 and later versions. PostgreSQL is known for its advanced features, standards compliance, and extensibility.
Quick Setup
Open Connection Form
Click New Connection from the Welcome screen or File > New Connection
Select PostgreSQL
Choose PostgreSQL from the database type selector
Enter Connection Details
Fill in host, port, username, password, and database name
Test and Connect
Click Test Connection, then Create
Connection Settings
Required Fields
| Field | Description | Default |
|---|
| Name | Connection identifier | - |
| Host | Server hostname or IP | localhost |
| Port | PostgreSQL server port | 5432 |
| Username | PostgreSQL user | postgres |
| Password | User password | - |
| Database | Database name to connect to | - |
Unlike MySQL, PostgreSQL requires specifying a database name to connect.
Example Configurations
Local Development Server
Name: Local PostgreSQL
Host: localhost
Port: 5432
Username: postgres
Password: (your password)
Database: postgres
Docker PostgreSQL Container
Name: Docker Postgres
Host: localhost
Port: 5432 (or your mapped port)
Username: postgres
Password: (password from POSTGRES_PASSWORD)
Database: postgres
Homebrew PostgreSQL
Name: Homebrew Postgres
Host: localhost
Port: 5432
Username: (your macOS username)
Password: (empty for local trust auth)
Database: postgres
Homebrew PostgreSQL often uses “trust” authentication for local connections, meaning no password is required.
Remote Server
Name: Production DB
Host: db.example.com
Port: 5432
Username: app_user
Password: (secure password)
Database: myapp_production
Cloud Databases
Amazon RDS
Name: AWS RDS Postgres
Host: mydb.abc123.us-east-1.rds.amazonaws.com
Port: 5432
Username: postgres
Password: (your RDS password)
Database: postgres
Heroku Postgres
Name: Heroku Postgres
Host: ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com
Port: 5432
Username: (from DATABASE_URL)
Password: (from DATABASE_URL)
Database: (from DATABASE_URL)
Parse your Heroku DATABASE_URL to extract host, port, username, password, and database name.
Features
Schema Support
PostgreSQL organizes tables into schemas. TablePro displays:
- All schemas accessible to your user
- Tables within each schema
- The search path order
For each table, TablePro shows:
- Structure: Columns with PostgreSQL-specific types
- Indexes: Including partial and expression indexes
- Constraints: Primary keys, foreign keys, check constraints
- DDL: The CREATE TABLE statement
Query Execution
Execute queries with full PostgreSQL syntax support:
-- JSONB queries
SELECT data->>'name' as name, data->'address'->>'city' as city
FROM customers
WHERE data @> '{"active": true}'::jsonb;
-- Array operations
SELECT name, tags
FROM products
WHERE 'electronics' = ANY(tags);
-- Window functions
SELECT
department,
employee,
salary,
salary - LAG(salary) OVER (PARTITION BY department ORDER BY hire_date) as salary_change
FROM employees;
-- CTEs with RETURNING
WITH inserted AS (
INSERT INTO orders (customer_id, total)
VALUES (1, 99.99)
RETURNING *
)
SELECT * FROM inserted;
-- Full-text search
SELECT title, ts_rank(search_vector, query) as rank
FROM articles, to_tsquery('english', 'database & performance') query
WHERE search_vector @@ query
ORDER BY rank DESC;
PostgreSQL-Specific Types
TablePro properly displays PostgreSQL’s rich type system:
| Type | Display |
|---|
jsonb | Formatted JSON |
array | Array notation |
uuid | UUID string |
inet | IP address |
timestamp with time zone | Localized timestamp |
interval | Human-readable duration |
bytea | Binary data indicator |
Troubleshooting
Connection Refused
Symptoms: “Connection refused” or “could not connect to server”
Causes and Solutions:
-
PostgreSQL server not running
# Check if PostgreSQL is running
pg_isready -h localhost -p 5432
# Start PostgreSQL (macOS with Homebrew)
brew services start postgresql@16
-
PostgreSQL not accepting connections
- Check
listen_addresses in postgresql.conf
- For remote connections, set
listen_addresses = '*'
-
Firewall blocking connections
- Check macOS firewall settings
- Verify port 5432 is accessible
Authentication Failed
Symptoms: “password authentication failed” or “Peer authentication failed”
Understanding pg_hba.conf:
PostgreSQL uses pg_hba.conf to control authentication. Common entries:
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
Solutions:
- For password auth: Ensure
md5 or scram-sha-256 is set
- For local development: Use
trust (no password required)
- Reset password if forgotten:
ALTER USER postgres WITH PASSWORD 'newpassword';
Database Does Not Exist
Symptoms: “database ‘xyz’ does not exist”
Solution: Connect to an existing database first (usually postgres), then create your database:
Permission Denied
Symptoms: “permission denied for table” or “permission denied for schema”
Solutions:
-
Check current permissions:
SELECT * FROM information_schema.role_table_grants
WHERE grantee = 'username';
-
Grant necessary permissions:
GRANT ALL ON DATABASE mydb TO username;
GRANT ALL ON SCHEMA public TO username;
GRANT ALL ON ALL TABLES IN SCHEMA public TO username;
SSL/TLS Connections
TablePro supports SSL/TLS encryption for PostgreSQL connections. Configure SSL in the SSL/TLS section of the connection form.
| SSL Mode | PostgreSQL sslmode | Description |
|---|
| Disabled | disable | No SSL encryption |
| Preferred | prefer | Use SSL if available, fall back to unencrypted |
| Required | require | Require SSL, but don’t verify certificates |
| Verify CA | verify-ca | Require SSL and verify the server certificate against a CA |
| Verify Identity | verify-full | Require SSL, verify CA, and verify the server hostname |
For Verify CA and Verify Identity modes, provide the path to your CA certificate (root certificate). You can also provide optional client certificate and key files for mutual TLS authentication.
Cloud providers like AWS RDS, Heroku, and Supabase typically require SSL. Use Required or Verify CA mode depending on your security needs.
If you prefer not to configure SSL certificates, SSH tunneling is an alternative that encrypts all traffic through an SSH tunnel.
PostgreSQL Extensions
TablePro works with databases using popular extensions:
| Extension | Support |
|---|
postgis | Displays geometry/geography types |
pg_trgm | Full query support |
uuid-ossp | UUID display |
hstore | Key-value display |
ltree | Tree path display |
To see installed extensions:
SELECT * FROM pg_extension;
Query Analysis
Use EXPLAIN ANALYZE to understand query performance:
EXPLAIN ANALYZE
SELECT * FROM users WHERE email LIKE '%@example.com';
Connection Limits
PostgreSQL has a default connection limit. Monitor connections:
SELECT count(*) FROM pg_stat_activity;
Large Tables
For tables with millions of rows:
- Always use
LIMIT in exploratory queries
- Create appropriate indexes
- Use pagination in the data grid
Differences from MySQL
If you’re coming from MySQL:
| MySQL | PostgreSQL |
|---|
SHOW DATABASES | \l or query pg_database |
SHOW TABLES | \dt or query information_schema.tables |
DESCRIBE table | \d table or query information_schema.columns |
AUTO_INCREMENT | SERIAL or GENERATED AS IDENTITY |
LIMIT x, y | LIMIT y OFFSET x |
| Backtick quotes | Double quotes for identifiers |
Next Steps