{"id":13647651,"url":"https://github.com/sunng87/pgwire","last_synced_at":"2026-04-15T08:02:30.932Z","repository":{"id":50381458,"uuid":"502240118","full_name":"sunng87/pgwire","owner":"sunng87","description":"PostgreSQL wire protocol implemented as a rust library.","archived":false,"fork":false,"pushed_at":"2025-05-01T12:14:40.000Z","size":895,"stargazers_count":567,"open_issues_count":20,"forks_count":53,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-01T13:26:28.566Z","etag":null,"topics":["database","postgresql","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/sunng87.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","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},"funding":{"github":"sunng87","liberapay":"Sunng"}},"created_at":"2022-06-11T03:30:09.000Z","updated_at":"2025-04-27T13:49:22.000Z","dependencies_parsed_at":"2024-01-14T12:45:30.987Z","dependency_job_id":"e14c4f4f-1be9-4808-82d1-9aaa9da835e6","html_url":"https://github.com/sunng87/pgwire","commit_stats":{"total_commits":539,"total_committers":20,"mean_commits":26.95,"dds":0.1558441558441559,"last_synced_commit":"5374828b0bbc8de959be5b3381b5b4a7d5c3d6f9"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunng87%2Fpgwire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunng87%2Fpgwire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunng87%2Fpgwire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunng87%2Fpgwire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunng87","download_url":"https://codeload.github.com/sunng87/pgwire/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043307,"owners_count":22004922,"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":["database","postgresql","rust"],"created_at":"2024-08-02T01:03:41.440Z","updated_at":"2026-04-01T18:09:06.080Z","avatar_url":"https://github.com/sunng87.png","language":"Rust","funding_links":["https://github.com/sponsors/sunng87","https://liberapay.com/Sunng"],"categories":["Rust"],"sub_categories":[],"readme":"# pgwire\n\n[![CI](https://github.com/sunng87/pgwire/actions/workflows/ci.yml/badge.svg)](https://github.com/sunng87/pgwire/actions/workflows/ci.yml)\n[![](https://img.shields.io/crates/v/pgwire)](https://crates.io/crates/pgwire)\n[![Docs](https://docs.rs/pgwire/badge.svg)](https://docs.rs/pgwire/latest/pgwire/)\n\nBuild Postgres compatible access layer for your data service.\n\nThis library implements PostgreSQL Wire Protocol, and provide essential APIs to\nwrite PostgreSQL compatible servers and clients. It's like\n[hyper](https://github.com/hyperium/hyper/), but for postgres wire protocol.\n\nThe\n[datafusion-postgres](https://github.com/datafusion-contrib/datafusion-postgres)\nproject is a more complete library built on top of pgwire, with datafusion as\nquery engine, as well as pg_catalog implementation over datafusion.\n\nIf you are interested in related topic, you can check [project\nideas](https://github.com/sunng87/pgwire/discussions/204) to build on top of\nthis library.\n\n\n## Status\n\n- Message format\n  - [x] Frontend-Backend protocol messages\n    - [x] 3.0\n    - [x] 3.2, Postgres 18\n  - [ ] Streaming replication protocol\n  - [ ] Logical streaming replication protocol message\n- [x] Backend TCP/TLS server on Tokio\n- [ ] Frontend TCP/TLS client on Tokio\n- Frontend-Backend interaction over TCP\n  - [x] SSL Request and Response\n    - [x] PostgreSQL 17 direct SSL negotiation\n  - [x] GSSAPI Request and Response: GSSAPI encryption is not supported\n  - [x] Startup\n    - [x] Protocol negotiation\n    - [x] No authentication\n    - [x] Clear-text password authentication\n    - [x] Md5 Password authentication\n    - [x] SASL SCRAM authentication\n      - [x] SCRAM-SHA-256\n      - [x] SCRAM-SHA-256-PLUS\n    - [x] SASL OAUTH\n  - [x] Simple Query and Response\n  - [x] Extended Query and Response\n    - [x] Parse\n    - [x] Bind\n    - [x] Execute\n    - [x] Describe\n    - [x] Sync\n  - [x] Termination\n  - [x] Cancel\n  - [x] Error and Notice\n  - [x] Copy\n  - [x] Notification\n- [ ] Streaming replication over TCP\n- [ ] Logical streaming replication over TCP\n- [x] Data types\n  - [x] Text format\n  - [x] Binary format, implemented in `postgres-types`\n- APIs\n  - Backend/Server\n    - [x] Startup APIs\n      - [x] AuthSource API, fetching and hashing passwords\n      - [x] Server parameters API, ready but not very good\n    - [x] Simple Query API\n    - [x] Extended Query API\n      - [x] QueryParser API, for transforming prepared statement\n    - [x] ResultSet builder/encoder API\n    - [x] Query Cancellation API\n    - [x] Error and Notice API\n    - [x] Copy API\n      - [x] Copy-in\n      - [x] Copy-out\n      - [x] Copy-both\n    - [x] Transaction state\n    - [ ] Streaming replication over TCP\n    - [ ] Logical streaming replication server API\n  - Frontend/Client\n    - [x] Startup APIs\n    - [x] Simple Query API\n    - [ ] Extended Query API\n    - [ ] ResultSet decoder API\n    - [ ] Query Cancellation API\n    - [ ] Error and Notice API\n    - [ ] Copy API\n    - [ ] Transaction state\n    - [ ] Streaming replication over TCP\n    - [ ] Logical streaming replication server API\n\n## About Postgres Wire Protocol\n\nPostgres Wire Protocol is a relatively general-purpose Layer-7 protocol. There\nare 6 parts of the protocol:\n\n- Startup: client-server handshake and authentication.\n- Simple Query: The text-based query protocol of postgresql. Query are provided\n  as string, and server is allowed to stream data in response.\n- Extended Query: A new sub-protocol for query which has ability to cache the\n  query on server-side and reuse it with new parameters. The response part is\n  identical to Simple Query.\n- Copy: the subprotocol to copy data from and to postgresql.\n- Replication\n- Logical Replication\n\nAlso note that Postgres Wire Protocol has no semantics about SQL, so literally\nyou can use any query language, data formats or even natural language to\ninteract with the backend.\n\nThe response are always encoded as data row format. And there is a field\ndescription as header of the data to describe its name, type and format.\n\n[Jelte Fennema-Nio](https://github.com/JelteF)'s on talk on PgConf.dev 2024 has\na great coverage of how the wire protocol works:\nhttps://www.youtube.com/watch?v=nh62VgNj6hY\n\n## Usage\n\n### Server/Backend\n\nTo use `pgwire` in your server application, you will need to implement two key\ncomponents: **startup processor** and **query processor**. For query\nprocessing, there are two kinds of queries: simple and extended. By adding\n`SimpleQueryHandler` to your application, you will get `psql` command-line tool\ncompatibility. And for more language drivers and additional prepared statement,\nbinary encoding support, `ExtendedQueryHandler` is required.\n\nExamples are provided to demo the very basic usage of `pgwire` on server side:\n\n- `examples/sqlite.rs`: uses an in-memory sqlite database at its core and serves\n  it with postgresql protocol. This is a full example with both simple and\n  extended query implementation. `cargo run --features _sqlite --example\n  sqlite`\n- `examples/duckdb.rs`: Now moved to\n  [pgwire-duckdb](https://github.com/sunng87/pgwire-duckdb)\n- `examples/gluesql.rs`: uses an in-memory\n  [gluesql](https://github.com/gluesql/gluesql) at its core and serves\n  it with postgresql protocol.\n- `examples/server.rs`: demos a server that always returns fixed results.\n- `examples/secure_server.rs`: demos a server with ssl support and always\n  returns fixed results.\n- `examples/scram.rs`: demos how to configure more secure authentication\n  mechanism:\n  [SCRAM](https://en.wikipedia.org/wiki/Salted_Challenge_Response_Authentication_Mechanism)\n- `examples/transaction.rs`: see how to control transaction state at wire\n  protocol level.\n- `examples/datafusion.rs`: Now moved to\n  [datafusion-postgres](https://github.com/sunng87/datafusion-postgres)\n- `examples/oauth.rs`, `examples/keycloak_oauth.rs`: Examples for Postgres 18\n  OAuth authentication.\n\n### Client/Frontend\n\nThe client/frontend API is progress of development. This API will focus on\nproviding full access of postgres wire protocol. It's designed to build\ncomponents like postgres proxy. For general purpose postgres driver for\napplication development, you can use\n[rust-postgres](https://github.com/sfackler/rust-postgres).\n\n## Projects using pgwire\n\n* [GreptimeDB](https://github.com/GrepTimeTeam/greptimedb): Cloud-native\n  time-series database\n* [risinglight](https://github.com/risinglightdb/risinglight): OLAP database\n  system for educational purpose\n* [PeerDB](https://github.com/PeerDB-io/peerdb) Postgres first ETL/ELT, enabling\n  10x faster data movement in and out of Postgres, acquired by Clickhouse\n* [CeresDB](https://github.com/CeresDB/ceresdb) CeresDB is a high-performance,\n  distributed, cloud native time-series database from AntGroup.\n* [dozer](https://github.com/getdozer/dozer) a real-time data platform for\n  building, deploying and maintaining data products.\n* [pg_catalog](https://github.com/ybrs/pg_catalog) Provides a postgres\n  compatibility layer for custom databases.\n* [SpacetimeDB](https://github.com/clockworklabs/SpacetimeDB) The database for\n  multiplayer games. It's using pgwire for postgres protocol interface.\n* [corrosion](https://github.com/superfly/corrosion) from fly.io: Gossip-based\n  service discovery (and more) for large distributed systems.\n* [db9.ai](https://db9.ai/): Postgres but for agents.\n\n\nSubmit a pull request if your project isn't listed here.\n\n## Community\n\n### Developer Mailing List\n\nIf you like the idea of pgwire and want to join the development of the library,\nor its ecosystem integrations, extensions, you are welcomed to join our\ndeveloper mailing list: https://groups.io/g/pgwire-dev/\n\n### Github Discussion\n\nGithub discussion of this repo is also open for more generate questions.\n\n## License\n\nThis library is released under MIT/Apache dual license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunng87%2Fpgwire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunng87%2Fpgwire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunng87%2Fpgwire/lists"}