{"id":18539316,"url":"https://github.com/broady/gae-postgres","last_synced_at":"2025-10-27T23:07:09.364Z","repository":{"id":57510966,"uuid":"109937937","full_name":"broady/gae-postgres","owner":"broady","description":"Connect to Cloud SQL for PostgreSQL from Google App Engine","archived":false,"fork":false,"pushed_at":"2018-06-25T18:23:29.000Z","size":10,"stargazers_count":23,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T09:47:07.437Z","etag":null,"topics":["appengine","appengine-go","cloud-sql","go","golang","postgres","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/broady.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-08T06:41:33.000Z","updated_at":"2020-04-28T18:56:06.000Z","dependencies_parsed_at":"2022-09-26T17:50:16.031Z","dependency_job_id":null,"html_url":"https://github.com/broady/gae-postgres","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broady%2Fgae-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broady%2Fgae-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broady%2Fgae-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broady%2Fgae-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/broady","download_url":"https://codeload.github.com/broady/gae-postgres/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248078616,"owners_count":21044142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appengine","appengine-go","cloud-sql","go","golang","postgres","postgresql"],"created_at":"2024-11-06T19:48:04.949Z","updated_at":"2025-10-27T23:07:09.290Z","avatar_url":"https://github.com/broady.png","language":"Go","readme":"# Cloud SQL for PostgreSQL on Google App Engine\n\n[GoDoc](https://godoc.org/github.com/broady/gae-postgres)\n\n## Disclaimer\n\nThis is not a Google product, and is unsupported.\n\nIt uses the `google.golang.org/appengine/cloudsql` package, which is supported for MySQL, but not for Postgres.\n\nIt happens to work right now, but may not forever.\n\n\n## Example\n\napp.yaml\n\n```yaml\nruntime: go\napi_version: go1\n\nhandlers:\n- url: /.*\n  script: _go_app\n\nenv_variables:\n  # Replace INSTANCE_CONNECTION_NAME with the value obtained when configuring your\n  # Cloud SQL instance, available from the Google Cloud Console or from the Cloud SDK.\n  # For Cloud SQL 2nd generation instances, this should be in the form of \"project:region:instance\".\n  CLOUDSQL_CONNECTION_NAME: 'INSTANCE_CONNECTION_NAME'\n  # Replace username and password if you aren't using the root user.\n  CLOUDSQL_USER: postgres\n  CLOUDSQL_PASSWORD: pw\n```\n\ncloudsql.go\n\n```go\n// Copyright 2017 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\n// Sample cloudsql_postgres demonstrates connection to a Cloud SQL for Postgres instance from App Engine standard.\npackage main\n\nimport (\n\t\"bytes\"\n\t\"database/sql\"\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\t\"os\"\n\n\t\"google.golang.org/appengine\"\n\n\t_ \"github.com/broady/gae-postgres\"\n)\n\nvar db *sql.DB\n\nfunc main() {\n\tvar (\n\t\tconnectionName = mustGetenv(\"CLOUDSQL_CONNECTION_NAME\")\n\t\tuser           = mustGetenv(\"CLOUDSQL_USER\")\n\t\tpassword       = os.Getenv(\"CLOUDSQL_PASSWORD\") // NOTE: password may be empty\n\t)\n\n\tvar err error\n\tdb, err = sql.Open(\"gae-postgres\", fmt.Sprintf(\"cloudsql=%s user=%s password='%s'\", connectionName, user, password))\n\tif err != nil {\n\t\tlog.Fatalf(\"Could not open db: %v\", err)\n\t}\n\n\thttp.HandleFunc(\"/\", handler)\n\tappengine.Main()\n}\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tif r.URL.Path != \"/\" {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\n\trows, err := db.Query(\"SELECT datname FROM pg_database\")\n\tif err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Could not query db: %v\", err), 500)\n\t\treturn\n\t}\n\tdefer rows.Close()\n\n\tbuf := bytes.NewBufferString(\"Databases:\\n\")\n\tfor rows.Next() {\n\t\tvar dbName string\n\t\tif err := rows.Scan(\u0026dbName); err != nil {\n\t\t\thttp.Error(w, fmt.Sprintf(\"Could not scan result: %v\", err), 500)\n\t\t\treturn\n\t\t}\n\t\tfmt.Fprintf(buf, \"- %s\\n\", dbName)\n\t}\n\tw.Write(buf.Bytes())\n}\n\nfunc mustGetenv(k string) string {\n\tv := os.Getenv(k)\n\tif v == \"\" {\n\t\tlog.Panicf(\"%s environment variable not set.\", k)\n\t}\n\treturn v\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroady%2Fgae-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbroady%2Fgae-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroady%2Fgae-postgres/lists"}