axum_odbc 0.1.0

Library to Provide an ODBC-Api layer.
docs.rs failed to build axum_odbc-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: axum_odbc-0.8.0

AxumODBC

Library to Provide an ODBC-Api layer.

https://crates.io/crates/axum_axum_odbc Docs

Install

Axum ODBC uses tokio runtime.

# Cargo.toml
[dependencies]
axum_odbc = "0.1.0"

Cargo Feature Flags

iodbc: Sets odbc-api to use iodbc connection manager.

Example

use axum_odbc::{OdbcManagerLayer, ODBCConnectionManager, blocking};
use axum::{
    Router,
    routing::get,
};

#[tokio::main]
async fn main() {

    let manager = ODBCConnectionManager::new("Driver={ODBC Driver 17 for SQL Server};Server=localhost;UID=SA;PWD=My@Test@Password1;", 5);

    // build our application with some routes
    let app = Router::new()
        .route("/drop", get(drop_table))
        .layer(OdbcManagerLayer::new(manager));

    // run it
    let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
    tracing::debug!("listening on {}", addr);
    axum::Server::bind(&addr)
        .serve(app.into_make_service())
        .await
        .unwrap();
}

async fn drop_table(manager: ODBCConnectionManager) -> String {
    let mut connection = manager.aquire().await.unwrap();

    let _ = blocking!(connection.execute("DROP TABLE IF EXISTS TEST", ())).unwrap();

    "compeleted".to_string()
}

Help

If you need help with this library or have suggestions please go to our Discord Group