Git Product home page Git Product logo

axumodbc's Introduction

AxumODBC

Library to Provide an ODBC-API layer.

crates.io docs.rs Minimum Rust Version

License

This project is licensed under either Apache License, Version 2.0, zlib License, or MIT License, at your option.

Help

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

Install

Axum ODBC uses tokio runtime.

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

Cargo Feature Flags

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

Example

use axum_odbc::{ODBCConnectionManager, blocking};
use axum::{
    Router,
    routing::get,
};
use std::time::Duration;

#[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::with_state(manager)
        .route("/drop", get(drop_table));

    // 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 sleep = || tokio::time::sleep(Duration::from_millis(50));

    let _ = connection.execute_polling("DROP TABLE IF EXISTS TEST", (), sleep).await.unwrap();

    "compeleted".to_string()
}

axumodbc's People

Contributors

genusistimelord avatar

Stargazers

Emil avatar  avatar Matteo Di Mattia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.