2 unstable releases
0.2.0 | Oct 6, 2022 |
---|---|
0.1.0 | Jul 6, 2022 |
#2065 in Database interfaces
34KB
1K
SLoC
datastore-mysql
A datastore Store implementation using the MySQL database.
Usage
Add this to your Cargo.toml
:
datastore-mysql = "0.1.0"
More information can be found on docs.rs.
License
This project is licensed under either the MIT License or Apache License, Version 2.0 at your option.
lib.rs
:
datastore-mysql
This crate provides MySqlStore
which is a Store
implementation using the MySQL
database.
MySqlStore
supports these types:
bool
i8
,i16
,i32
,i64
u8
,u16
,u32
,u64
f32
,f64
&str
,String
&[u8]
,Vec<u8>
Examples
use datastore::{Store, StoreExt, StoreData};
use datastore_mysql::MySqlStore;
#[derive(Debug, StoreData)]
pub struct Person {
id: i64,
name: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = MySqlStore::connect("mysql://user:password@host/database").await?;
let person = Person {
id: 1,
name: String::from("Robb"),
};
store.insert(store.descriptor::<Person>(), person).await?;
let persons: Vec<Person> = store.get_all(store.descriptor::<Person>()).await?;
println!("{:?}", persons);
Ok(())
}
Dependencies
~22–34MB
~637K SLoC