claude-memory/graph/code-patterns/cloudsql-write-to-cloudsql-pattern-with-postgres-function-6d3dcf.md
Cal Corum b140d4d82a migrate: 313 memories from MemoryGraph
- 313 new markdown files created
- 30 relationships embedded
- 313 entries indexed
- State initialized with usage data
2026-02-13 11:11:48 -06:00

1.1 KiB

id type title tags importance confidence created updated relations
6d3dcf69-9c0c-4d8a-b1a7-27267c07da51 code_pattern CloudSQL write_to_cloudsql pattern with Postgres function
esb-monorepo
object-handler
python
cloudsql
pattern
0.7 0.8 2025-12-10T19:55:28.150687+00:00 2025-12-10T19:55:28.150687+00:00
target type direction strength
db7cb384-b686-4afc-956c-ff74861a11cc SOLVES incoming 0.5
target type direction strength
e80e161a-4be4-428d-8590-267b9ab4cc7c BUILDS_ON incoming 0.5

Pattern for calling Postgres upsert functions from Python via Cloud SQL Connector: (1) Strip unwanted fields (e.g., raw_data) before sending, (2) Build function name from object_type: fn_upsert_{object_type.lower()}, (3) Pass data as JSONB: cursor.execute('SELECT fn_upsert_account(%s::jsonb)', (json.dumps(data),)), (4) Use connection singleton for serverless pooling, (5) Always close connection in finally block. Env vars: CLOUDSQL_INSTANCE, CLOUDSQL_USER, CLOUDSQL_DATABASE, CLOUDSQL_IAM_AUTH, CLOUDSQL_PASSWORD (if not IAM).