mysql_helper

Crates.iomysql_helper
lib.rsmysql_helper
version0.1.6
sourcesrc
created_at2022-06-22 00:32:25.583665
updated_at2022-06-22 04:08:53.615017
descriptionMake mysql to struct simple with macro
homepage
repositoryhttps://github.com/changpengdiao/mysql-helper/
max_upload_size
id610600
size4,413
dcp (changpengdiao)

documentation

README

mysql_helper

Make mysql to struct simple with macro

Example

Create a strcut which the feilds same with mysql-table feilds

use mysql_helper::ModelHelper;
use std::ops::Index;
#[derive(ModelHelper)]
struct CustomStrcut{
    pub c_id : Option<i64>,
    pub c_name : Option<String>,
}

Conn is mysql connection,Create connection,see mysql. ModelHelper will helper you create 'mysql_to_vo' method

let v:Vec<CustomStrcut> = conn.query_map("select * from xxx",|row:Row|CustomStrcut::mysql_to_vo(row));
Commit count: 11

cargo fmt