crudx
sql crud
Cargo Feature Flags
-
postgres: Using SQLX to call Postgres database -
mysql: Using SQLX to call MySQL database -
sqlite: Using SQLX to call SQLite database -
mssql: Using Tiberius to call MsSQL database -
async_trait: Using async-trait macros during asynchronous calls
Generate data table
;
(
`pid` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` varchar(50) CHARACTER SET utf8 NOT NULL,
`user_ip` varchar(50) CHARACTER SET utf8 NOT NULL,
`optime` varchar(50) CHARACTER SET utf8 NOT NULL,
`operation` varchar(4000) CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`pid`)
) ENGINE=InnoDB AUTO_INCREMENT=17542563 DEFAULT CHARSET=utf8;
Build entity
use StructIndex;
Connect to database
Refer to SQLX configuration
use MySqlPool;
let pool = connect
.await
.unwrap;
Insert a data entry
use ;
let oplog = Oplog ;
let res = new
.bind
.insert_one
.await
.unwrap;
println!;
Insert some data
use ;
let res = new
.bind
.insert
.await
.unwrap;
println!;
Update one piece of data
use ;
let oplog = Oplog ;
let mut filter = default;
filter.and;
let res = new
.bind
.update
.await
.unwrap;
println!;
Delete data
use ;
let oplog = default;
let mut filter = default;
filter.and;
let res = new
.bind
.delete
.await
.unwrap;
println!;
Query data
use ;
let oplog = default;
let mut filter = default;
filter.and;
filter.and;
let res = new
.bind
.order_by
.limit
.query
.await
.unwrap;
println!;
License
crudx is provided under the MIT license. See LICENSE.