Cloud SQL
TCP · port 5432 · orchestrated
Orchestrated service. Cloud SQL runs as a PostgreSQL 16 container managed by localgcp. Requires Docker. Container starts lazily on first connection.
Quick start
$ localgcp up --services=cloudsql
Connecting
Cloud SQL exposes a standard PostgreSQL connection on localhost:5432 with trust authentication (no password required). Connect with any Postgres client or driver:
$ psql -h localhost -p 5432 -U postgres -d localgcp
Works with psql, pgAdmin, DBeaver, or any PostgreSQL client library.
Go example
Connect with database/sql and lib/pq or pgx:
package main import ( "database/sql" "fmt" "log" _ "github.com/lib/pq" ) func main() { db, err := sql.Open("postgres", "host=localhost port=5432 user=postgres dbname=localgcp sslmode=disable", ) if err != nil { log.Fatal(err) } defer db.Close() if err := db.Ping(); err != nil { log.Fatal(err) } fmt.Println("connected to Cloud SQL (localgcp)") }
Python example
Connect with psycopg2:
import psycopg2 conn = psycopg2.connect( host="localhost", port=5432, user="postgres", dbname="localgcp", ) cur = conn.cursor() cur.execute("SELECT 1") print(cur.fetchone()) conn.close()
How it works
- Lazy TCP proxy -- localgcp listens on port 5432 and starts the PostgreSQL container on first connection
- postgres:16-alpine -- lightweight PostgreSQL 16 image pulled automatically
- Trust authentication -- no password required, connections are accepted from localhost
- Database pre-created -- the
localgcpdatabase is created automatically on startup
Not yet supported
- Data persistence across restarts
- Multiple databases
- Cloud SQL Auth Proxy compatibility