tiberius-mssql-broker

Crates.iotiberius-mssql-broker
lib.rstiberius-mssql-broker
version0.1.3
sourcesrc
created_at2023-07-25 00:55:30.237172
updated_at2023-07-25 00:57:10.295627
descriptionReal time change listener for MSSQL
homepage
repositoryhttps://github.com/mjm918/tiberius-mssql-broker
max_upload_size
id925076
size64,564
Mohammad Julfikar (mjm918)

documentation

README

Tiberius MSSQL Broker

Broker for MSSQL. Re-implementation of C# SQLDependencyEx.

Thanks to deadpool-tiberius repository.

Example:

broker example

let mssql = MssqlConnection::establish(&SqlConfig{
    host: ".".to_string(),
    instance: Some("SQLEXPRESS".to_string()),
    port: 1433,
    username: "sa".to_string(),
    password: "julfikar123@".to_string(),
    database: "AED_MOBILE".to_string(),
    trust_cert: true,
    allow_encrypt: true,
    max_pool: 1,
    sql_browser: false,
}).await;
match mssql {
    Ok(conn) => {
        let (sx, rx) = kanal::unbounded::<Vec<ListenEvent>>();
        println!("started listening...");
        tokio::spawn(async move {
            while let Ok(evs) = rx.recv() {
                println!("{} {:?}",evs.len(),evs);
            }
        });
        let broker = conn.listen(1,format!("IV"), sx).await;
        match broker {
            Ok(_) => { }
            Err(err) => {
                println!("{:?}",err);
            }
        }
    }
    Err(err) => {
        println!("{:?}",err);
    }
}

query example

let config = SqlConfig {
    host: ".".to_string(),
    instance: Some("SQLEXPRESS".to_string()),
    port: 1433,
    username: "sa".to_string(),
    password: "julfikar123@".to_string(),
    database: "AED_MOBILE".to_string(),
    trust_cert: true,
    allow_encrypt: true,
    max_pool: 1,
    sql_browser: false,
};

let mssql = MssqlConnection::establish(&config).await;
let mut mssql = mssql.unwrap();

let res = mssql.select("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';", vec![]).await;
let res: Vec<HashMap<String,Value>> = res.unwrap();
Commit count: 13

cargo fmt