PostgreSQL is a powerful, open-source relational database system known for its reliability, feature robustness, and performance. Queryly provides full support for connecting to and managing PostgreSQL databases.
# Standard local connectionHost=localhost;Database=myapp;Username=postgres;Password=mypass# With explicit port (default is 5432)Host=localhost;Port=5432;Database=myapp;Username=postgres;Password=mypass# Using IP addressHost=127.0.0.1;Database=myapp;Username=postgres;Password=mypass
Default PostgreSQL port is 5432. You can omit the Port parameter if using the default.
# Standard password authenticationHost=localhost;Database=myapp;Username=postgres;Password=mypass# User with @ symbol in usernameHost=localhost;Database=myapp;Username=user@domain;Password=mypass
Store connection strings securely. Consider using environment variables or secret management tools for production credentials.
While Queryly uses key-value pairs, PostgreSQL also supports URI format:
# URI format (if your provider supports it)postgresql://postgres:mypass@localhost:5432/myapp# With SSLpostgresql://postgres:mypass@localhost:5432/myapp?sslmode=require
Queryly primarily uses the key-value format shown in other tabs. URI format may be supported depending on the underlying Npgsql driver version.
queryly data query ProductionDB# Select queriesSQL> SELECT * FROM users LIMIT 10;SQL> SELECT COUNT(*) FROM orders;SQL> SELECT name, email FROM customers WHERE created_at > '2024-01-01';
# JSON queriesSQL> SELECT data->>'name' as name FROM users;SQL> SELECT * FROM orders WHERE metadata @> '{"status": "completed"}';# Array operationsSQL> SELECT * FROM posts WHERE tags @> ARRAY['postgresql'];# Full-text searchSQL> SELECT * FROM articles WHERE to_tsvector(content) @@ to_tsquery('database');# Window functionsSQL> SELECT name, salary, RANK() OVER (ORDER BY salary DESC) FROM employees;
# Database sizeSQL> SELECT pg_size_pretty(pg_database_size(current_database()));# Table sizesSQL> SELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) FROM pg_tables WHERE schemaname = 'public';# Active connectionsSQL> SELECT datname, count(*) FROM pg_stat_activity GROUP BY datname;# Current user and databaseSQL> SELECT current_user, current_database();
# Add connectionqueryly connect add# name: MyPostgres# type: PostgreSQL# connection string: Host=localhost;Database=myapp;Username=postgres;Password=mypass# Test connectionqueryly connect test MyPostgres# List all tablesqueryly schema list MyPostgres
# View schema as treequeryly schema tree MyPostgres# Check table structurequeryly schema info MyPostgres users# Browse table dataqueryly data browse MyPostgres users# Export to CSVqueryly data export MyPostgres users csv
# Enter query modequeryly data query MyPostgres# Analyze dataSQL> SELECT DATE(created_at), COUNT(*) FROM orders GROUP BY DATE(created_at) ORDER BY DATE(created_at);SQL> SELECT status, AVG(total_amount) FROM orders GROUP BY status;SQL> exit
Error: Connection refused or could not connect to serverSolutions:
Verify PostgreSQL is running: sudo systemctl status postgresql
Check the port: sudo netstat -plnt | grep 5432
Verify postgresql.conf has listen_addresses = '*' (or specific IP)
Check firewall rules: sudo ufw status
# Start PostgreSQLsudo systemctl start postgresql# Check if it's listeningsudo ss -tlnp | grep 5432
Authentication failed
Error: password authentication failed for userSolutions:
Verify username and password are correct
Check pg_hba.conf allows the authentication method
Ensure user has access to the database
# Reset passwordsudo -u postgres psqlpostgres=# ALTER USER postgres PASSWORD 'newpassword';# Grant database accesspostgres=# GRANT ALL PRIVILEGES ON DATABASE myapp TO myuser;
Database does not exist
Error: database "myapp" does not existSolutions:
Verify database name (case-sensitive)
Create the database if needed
# List databasessudo -u postgres psql -c "\l"# Create databasesudo -u postgres createdb myapp# Or in psqlsudo -u postgres psqlpostgres=# CREATE DATABASE myapp;
Too many connections
Error: sorry, too many clients alreadySolutions:
Close unused connections
Increase max_connections in postgresql.conf
Check for connection leaks
# Check current connectionssudo -u postgres psql -c "SELECT count(*) FROM pg_stat_activity;"# View connections by databasesudo -u postgres psql -c "SELECT datname, count(*) FROM pg_stat_activity GROUP BY datname;"
SSL connection issues
Error: SSL is not enabled on the serverSolutions:
Change SSL mode to Prefer or Disable for local development
Enable SSL in postgresql.conf if required
# For local developmentHost=localhost;Database=myapp;Username=postgres;Password=mypass;SSL Mode=Disable# Check SSL statussudo -u postgres psql -c "SHOW ssl;"
# Connection managementqueryly connect addqueryly connect listqueryly connect test MyPostgresqueryly connect remove MyPostgres# Schema explorationqueryly schema list MyPostgresqueryly schema info MyPostgres usersqueryly schema tree MyPostgres# Data operationsqueryly data browse MyPostgres usersqueryly data query MyPostgresqueryly data export MyPostgres users csvqueryly data export MyPostgres users json
Command Reference
See the complete command reference for all available options