{"id":15364815,"url":"https://github.com/hexilee/async-postgres","last_synced_at":"2025-07-04T06:35:25.817Z","repository":{"id":43347006,"uuid":"253172926","full_name":"Hexilee/async-postgres","owner":"Hexilee","description":"A runtime-independent asynchronus PostgreSQL client","archived":false,"fork":false,"pushed_at":"2022-03-07T15:31:39.000Z","size":53,"stargazers_count":33,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T21:16:10.374Z","etag":null,"topics":["async-await","database-access","postgresql-client","rust-lang"],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/Hexilee.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":"2020-04-05T06:46:15.000Z","updated_at":"2024-10-06T19:46:44.000Z","dependencies_parsed_at":"2022-09-02T18:32:15.889Z","dependency_job_id":null,"html_url":"https://github.com/Hexilee/async-postgres","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hexilee%2Fasync-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hexilee%2Fasync-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hexilee%2Fasync-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hexilee%2Fasync-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hexilee","download_url":"https://codeload.github.com/Hexilee/async-postgres/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249026654,"owners_count":21200484,"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":["async-await","database-access","postgresql-client","rust-lang"],"created_at":"2024-10-01T13:13:21.003Z","updated_at":"2025-04-15T07:30:46.435Z","avatar_url":"https://github.com/Hexilee.png","language":"Rust","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003easync-postgres\u003c/h1\u003e\n  \u003cp\u003e\u003cstrong\u003eA runtime-independent, asynchronous PostgreSQL client.\u003c/strong\u003e \u003c/p\u003e\n  \u003cp\u003e\n\n[![Stable Test](https://github.com/Hexilee/async-postgres/workflows/Stable%20Test/badge.svg)](https://github.com/Hexilee/async-postgres/actions)\n[![codecov](https://codecov.io/gh/Hexilee/async-postgres/branch/master/graph/badge.svg)](https://codecov.io/gh/Hexilee/async-postgres) \n[![Rust Docs](https://docs.rs/async-postgres/badge.svg)](https://docs.rs/async-postgres)\n[![Crate version](https://img.shields.io/crates/v/async-postgres.svg)](https://crates.io/crates/async-postgres)\n[![Download](https://img.shields.io/crates/d/async-postgres.svg)](https://crates.io/crates/async-postgres)\n[![MSRV-1.40](https://img.shields.io/badge/MSRV-1.40-blue.svg)](https://blog.rust-lang.org/2019/12/19/Rust-1.40.0.html)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Hexilee/async-postgres/blob/master/LICENSE)\n\n  \u003c/p\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\nThis crate is a wrapper of [tokio-postgres](https://crates.io/crates/tokio-postgres).\n\n### Pros\n\nRuntime-independent, can be used on any async runtime.\n\n### Usage\n\nAlmost the same with tokio-postgres.\n\n- TCP or UDS\n\n```rust\nuse async_postgres::connect;\nuse std::error::Error;\nuse async_std::task::spawn;\n\nasync fn play() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let url = \"host=localhost user=postgres\";\n    let (client, conn) = connect(url.parse()?).await?;\n    spawn(conn);\n    let row = client.query_one(\"SELECT * FROM user WHERE id=$1\", \u0026[\u00260]).await?;\n    let value: \u0026str = row.get(0);\n    println!(\"value: {}\", value);\n    Ok(())\n}\n```\n\n- TLS\n\n```rust\nuse async_postgres::connect_tls;\nuse native_tls::{Certificate, TlsConnector};\nuse postgres_native_tls::MakeTlsConnector;\nuse std::fs;\nuse std::error::Error;\nuse async_std::task::spawn;\n\nasync fn play() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let cert = fs::read(\"database_cert.pem\")?;\n    let cert = Certificate::from_pem(\u0026cert)?;\n    let connector = TlsConnector::builder()\n        .add_root_certificate(cert)\n        .build()?;\n    let connector = MakeTlsConnector::new(connector);\n    let url = \"host=localhost user=postgres sslmode=require\";\n    let (client, conn) = connect_tls(url.parse()?, connector).await?;\n    spawn(conn);\n    let row = client.query_one(\"SELECT * FROM user WHERE id=$1\", \u0026[\u00260]).await?;\n    let value: \u0026str = row.get(0);\n    println!(\"value: {}\", value);\n    Ok(())\n}\n```\n\n### Performance\n\nAlmost the same with tokio-postgres, \nyou can see a live benchmark [here](https://github.com/Hexilee/async-postgres/actions?query=workflow%3ABenchmark).\n\n### Develop\n\nRunning tests needs a postgres server and environment variables:\n- `TCP_URL=\"postgresql:///\u003cdb\u003e?host=\u003ctcp host\u003e\u0026port=\u003cport\u003e\u0026user=\u003cuser\u003e\u0026password=\u003cpasswd\u003e\"`\n- `UDS_URL=\"postgresql:///\u003cdb\u003e?host=\u003cpostgres uds dir\u003e\u0026port=\u003cport\u003e\u0026user=\u003cuser\u003e\u0026password=\u003cpasswd\u003e\"`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexilee%2Fasync-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexilee%2Fasync-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexilee%2Fasync-postgres/lists"}