1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//!
//! Now, the functions is to remember.
//! Can you be delect use model of rusqlite.
//!
use rusqlite::Connection;

///Create or open sqlite3 database, open if it exist, create if it not exist.
/// Open a new connection to a SQLite database. If a database does not exist at the path, one is created.
pub fn c_db<S: AsRef<str>>(s: S) -> rusqlite::Result<Connection> {
    let s = s.as_ref();
    let c = Connection::open(s)?;
    Ok(c)
}

///It execute a sql sentence
pub fn sql_execute<S: AsRef<str>>(db: Connection, sql: S) -> rusqlite::Result<()> {
    let s = sql.as_ref();
    db.execute(s, ())?;
    Ok(())
}

///It batch execute a sql.
///
///
pub fn sql_execute_batch<S: AsRef<str>>(db: Connection, sql: S) -> rusqlite::Result<()> {
    let s = sql.as_ref();
    db.execute_batch(s)?;
    Ok(())
}