A simple macro to generate a specified sql when we have a struct A.
For example:
#[derive(TableCreator)]
struct A <’a, T>{
#[table_ignore]
a: i32,
b: String,
c: &’a T
}
printfln!(“{}”, A::<’somelifetime, SomeType>::table_creat_sql()}
the output is :
CREATE TABLE IF NOT EXISTS A (id SERIAL PRIMARY KEY, b TEXT , c SomeMatchedSqlType )
The elements , with #[table_ignore], will be ignored.
It just support some Sqlite’s sql types:
i32| u32 | i64 | u64 => INTEGER,
f32 => REAL
f64 => REAL
String | str => TEXT
bool => BOOLEAN
NaiveDate => DATE
NaiveDateTime => TIMESTAMP