{"id":13837293,"url":"https://github.com/jackc/pgconn","last_synced_at":"2025-05-14T03:10:20.022Z","repository":{"id":37492918,"uuid":"178576091","full_name":"jackc/pgconn","owner":"jackc","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-25T16:04:10.000Z","size":342,"stargazers_count":190,"open_issues_count":24,"forks_count":87,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-14T00:50:40.699Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jackc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-03-30T15:26:30.000Z","updated_at":"2025-05-12T14:04:36.000Z","dependencies_parsed_at":"2024-01-13T17:10:31.325Z","dependency_job_id":"ec4548e6-f836-4c0d-99f7-bc1441e529e5","html_url":"https://github.com/jackc/pgconn","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackc%2Fpgconn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackc%2Fpgconn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackc%2Fpgconn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jackc%2Fpgconn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jackc","download_url":"https://codeload.github.com/jackc/pgconn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059512,"owners_count":22007769,"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":[],"created_at":"2024-08-04T15:01:05.541Z","updated_at":"2025-05-14T03:10:15.013Z","avatar_url":"https://github.com/jackc.png","language":"Go","readme":"[![](https://godoc.org/github.com/jackc/pgconn?status.svg)](https://godoc.org/github.com/jackc/pgconn)\n![CI](https://github.com/jackc/pgconn/workflows/CI/badge.svg)\n\n---\n\nThis version is used with pgx `v4`. In pgx `v5` it is part of the https://github.com/jackc/pgx repository. This `v4`\nversion will reach end-of-life on July 1, 2025. Only security bug fixes will be made to this version.\n\n---\n\n# pgconn\n\nPackage pgconn is a low-level PostgreSQL database driver. It operates at nearly the same level as the C library libpq.\nIt is primarily intended to serve as the foundation for higher level libraries such as https://github.com/jackc/pgx.\nApplications should handle normal queries with a higher level library and only use pgconn directly when required for\nlow-level access to PostgreSQL functionality.\n\n## Example Usage\n\n```go\npgConn, err := pgconn.Connect(context.Background(), os.Getenv(\"DATABASE_URL\"))\nif err != nil {\n\tlog.Fatalln(\"pgconn failed to connect:\", err)\n}\ndefer pgConn.Close(context.Background())\n\nresult := pgConn.ExecParams(context.Background(), \"SELECT email FROM users WHERE id=$1\", [][]byte{[]byte(\"123\")}, nil, nil, nil)\nfor result.NextRow() {\n\tfmt.Println(\"User 123 has email:\", string(result.Values()[0]))\n}\n_, err = result.Close()\nif err != nil {\n\tlog.Fatalln(\"failed reading result:\", err)\n}\n```\n\n## Testing\n\nThe pgconn tests require a PostgreSQL database. It will connect to the database specified in the `PGX_TEST_CONN_STRING`\nenvironment variable. The `PGX_TEST_CONN_STRING` environment variable can be a URL or DSN. In addition, the standard `PG*`\nenvironment variables will be respected. Consider using [direnv](https://github.com/direnv/direnv) to simplify\nenvironment variable handling.\n\n### Example Test Environment\n\nConnect to your PostgreSQL server and run:\n\n```\ncreate database pgx_test;\n```\n\nNow you can run the tests:\n\n```bash\nPGX_TEST_CONN_STRING=\"host=/var/run/postgresql dbname=pgx_test\" go test ./...\n```\n\n### Connection and Authentication Tests\n\nPgconn supports multiple connection types and means of authentication. These tests are optional. They\nwill only run if the appropriate environment variable is set. Run `go test -v | grep SKIP` to see if any tests are being\nskipped. Most developers will not need to enable these tests. See `ci/setup_test.bash` for an example set up if you need change\nauthentication code.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackc%2Fpgconn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackc%2Fpgconn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackc%2Fpgconn/lists"}