2 releases

0.4.2 Apr 25, 2022
0.4.1 Dec 15, 2021

#2572 in Database interfaces

MIT/Apache

50KB
757 lines

MySQL Async support for Toql

Add this to your Cargo.toml:

[dependencies]
toql = {version = "0.4", features = ["serde"]}
toql_mysql_async = "0.4"

And get your Toql with

use toql_mysql_async::{prelude::MySqlAsync, mysql_async::Pool};
use toql::prelude::Cache;

let database_url = "mysql://USER:PASS@localhost:3306/DATABASE";
let pool = Pool::new(database_url);
let mut conn = pool.get_conn().await?;
let cache = Cache::new();
let mut toql = MySqlAsync::from(conn, &cache);

A transaction can be started from a connection:

use toql_mysql_async::mysql_async::TxOpts;

// let conn = ...
// let cache = ...

let tx_opts = TxOpts::default();
let tx = conn.start_transaction(tx_opts).await?;
let mut toql = MySqlAsync::from(tx, &cache);

License

Toql MySqlAsync is distributed under the terms of both the MIT license and the Apache License (Version 2.0).


lib.rs:

MySQL Async support for Toql

Add this to your Cargo.toml:

[dependencies]
toql = {version = "0.3", features = ["serde"]}
toql_mysql_async = "0.3"

And get your Toql with

use toql_mysql_async::{prelude::MySqlAsync, mysql_async::Pool};
use toql::prelude::Cache;

let database_url = "mysql://USER:PASS@localhost:3306/DATABASE";
let pool = Pool::new(database_url);
let mut conn = pool.get_conn().await?;
let cache = Cache::new();
let mut toql = MySqlAsync::from(conn, &cache);

A transaction can be started from a connection:

use toql_mysql_async::mysql_async::TxOpts;

// let conn = ...
// let cache = ...

let tx_opts = TxOpts::default();
let tx = conn.start_transaction(tx_opts).await?;
let mut toql = MySqlAsync::from(tx, &cache);

License

Toql MySqlAsync is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

Dependencies

~21–36MB
~591K SLoC