All Projects → Hexilee → async-postgres

Hexilee / async-postgres

Licence: MIT License
A runtime-independent asynchronus PostgreSQL client

Programming Languages

rust
11053 projects
TSQL
950 projects

Projects that are alternatives of or similar to async-postgres

mongo orm
Mongo ORM: A simple ORM for using MongoDB with the crystal programming language, designed for use with Amber. Based loosely on Granite ORM. Supports Rails-esque models, associations and embedded documents.
Stars: ✭ 32 (+14.29%)
Mutual labels:  database-access
nardis
A small web framework based on ASGI
Stars: ✭ 14 (-50%)
Mutual labels:  async-await
modern-javascript
👨‍🏫 Mike's Modern JavaScript course
Stars: ✭ 14 (-50%)
Mutual labels:  async-await
wxapp-boilerplate
微信小程序开发脚手架 (ES6, Redux, Immutable-js, Async/await, Promise, Reselect, Babel, ESLint, Stylelint, Gulp ... )
Stars: ✭ 35 (+25%)
Mutual labels:  async-await
Rx.Book
High level asynchronous programming with Reactive Extensions
Stars: ✭ 67 (+139.29%)
Mutual labels:  async-await
apr
this is like caolan/async which is like lodash but async, but awaitful
Stars: ✭ 75 (+167.86%)
Mutual labels:  async-await
snap
Snap Programming Language
Stars: ✭ 20 (-28.57%)
Mutual labels:  async-await
express-mongoose-es8-rest-api
A Boilerplate for developing Rest api's in Node.js using express with support for ES6,ES7,ES8 ,Mongoose,JWT for authentication,Standardjs for linting
Stars: ✭ 20 (-28.57%)
Mutual labels:  async-await
await-outside
Await outside of async functions
Stars: ✭ 19 (-32.14%)
Mutual labels:  async-await
autocomplete
Simple accessible autocomplete for vanilla javacript with support for remote & local data, ~3KB gzip
Stars: ✭ 38 (+35.71%)
Mutual labels:  async-await
SwiftyContacts
A Swift library for Contacts framework.
Stars: ✭ 205 (+632.14%)
Mutual labels:  async-await
Shift
Light-weight EventKit wrapper.
Stars: ✭ 31 (+10.71%)
Mutual labels:  async-await
async-enumerable-dotnet
Experimental operators for C# 8 IAsyncEnumerables
Stars: ✭ 32 (+14.29%)
Mutual labels:  async-await
Rick-and-Morty-iOS-App
This is a sample iOS 13+ UIKit - Combine project.
Stars: ✭ 21 (-25%)
Mutual labels:  async-await
debounce-async
A debounce function that delays invoking asynchronous functions.
Stars: ✭ 21 (-25%)
Mutual labels:  async-await
GraphQL.RepoDB
A set of extensions for working with HotChocolate GraphQL and Database access with micro-orms such as RepoDb (or Dapper). This extension pack provides access to key elements such as Selections/Projections, Sort arguments, & Paging arguments in a significantly simplified facade so this logic can be leveraged in the Serivces/Repositories that enca…
Stars: ✭ 25 (-10.71%)
Mutual labels:  database-access
stateless-future
Asynchronous programming in fully featured Scala syntax.
Stars: ✭ 14 (-50%)
Mutual labels:  async-await
arraync
Async Array methods polyfills
Stars: ✭ 16 (-42.86%)
Mutual labels:  async-await
trimeter
(not ready yet) A simple but powerful job scheduler for Trio programs
Stars: ✭ 48 (+71.43%)
Mutual labels:  async-await
database
Advanced Database Access Service for Moleculer microservices framework
Stars: ✭ 22 (-21.43%)
Mutual labels:  database-access

async-postgres

A runtime-independent, asynchronous PostgreSQL client.

Stable Test codecov Rust Docs Crate version Download MSRV-1.40 License: MIT


This crate is a wrapper of tokio-postgres.

Pros

Runtime-independent, can be used on any async runtime.

Usage

Almost the same with tokio-postgres.

  • TCP or UDS
use async_postgres::connect;
use std::error::Error;
use async_std::task::spawn;

async fn play() -> Result<(), Box<dyn Error>> {
    let url = "host=localhost user=postgres";
    let (client, conn) = connect(url.parse()?).await?;
    spawn(conn);
    let row = client.query_one("SELECT * FROM user WHERE id=$1", &[&0]).await?;
    let value: &str = row.get(0);
    println!("value: {}", value);
    Ok(())
}
  • TLS
use async_postgres::connect_tls;
use native_tls::{Certificate, TlsConnector};
use postgres_native_tls::MakeTlsConnector;
use std::fs;
use std::error::Error;
use async_std::task::spawn;

async fn play() -> Result<(), Box<dyn Error>> {
    let cert = fs::read("database_cert.pem")?;
    let cert = Certificate::from_pem(&cert)?;
    let connector = TlsConnector::builder()
        .add_root_certificate(cert)
        .build()?;
    let connector = MakeTlsConnector::new(connector);
    let url = "host=localhost user=postgres sslmode=require";
    let (client, conn) = connect_tls(url.parse()?, connector).await?;
    spawn(conn);
    let row = client.query_one("SELECT * FROM user WHERE id=$1", &[&0]).await?;
    let value: &str = row.get(0);
    println!("value: {}", value);
    Ok(())
}

Performance

Almost the same with tokio-postgres, you can see a live benchmark here.

Develop

Running tests needs a postgres server and environment variables:

  • TCP_URL="postgresql:///<db>?host=<tcp host>&port=<port>&user=<user>&password=<passwd>"
  • UDS_URL="postgresql:///<db>?host=<postgres uds dir>&port=<port>&user=<user>&password=<passwd>"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].