Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/koka/r2d2-odbc
ODBC adapter for r2d2 connection pool
https://github.com/koka/r2d2-odbc
connection-pooling database odbc r2d2 rust
Last synced: 2 months ago
JSON representation
ODBC adapter for r2d2 connection pool
- Host: GitHub
- URL: https://github.com/koka/r2d2-odbc
- Owner: Koka
- License: mit
- Created: 2018-02-21T10:10:17.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-03T03:24:51.000Z (about 3 years ago)
- Last Synced: 2024-07-08T06:22:58.475Z (6 months ago)
- Topics: connection-pooling, database, odbc, r2d2, rust
- Language: Rust
- Size: 19.5 KB
- Stars: 9
- Watchers: 4
- Forks: 7
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# r2d2-odbc
# This crate is not maintained anymore
[ODBC](https://github.com/Koka/odbc-rs) adapter for [r2d2](https://github.com/sfackler/r2d2) connection pool
[![https://travis-ci.org/Koka/odbc-rs](https://travis-ci.org/Koka/r2d2-odbc.svg?branch=master)](https://travis-ci.org/Koka/r2d2-odbc)
[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/kyhokonmstsplla6?svg=true)](https://ci.appveyor.com/project/Koka/r2d2-odbc)
[![https://crates.io/crates/r2d2_odbc](https://meritbadge.herokuapp.com/r2d2_odbc#nocache8)](https://crates.io/crates/r2d2_odbc)
[![Coverage Status](https://coveralls.io/repos/github/Koka/r2d2-odbc/badge.svg)](https://coveralls.io/github/Koka/r2d2-odbc)
[![Docs](https://docs.rs/r2d2_odbc/badge.svg)](https://docs.rs/r2d2_odbc)Example:
```rust
extern crate r2d2;
extern crate r2d2_odbc;
extern crate odbc;use std::thread;
use r2d2_odbc::ODBCConnectionManager;
use odbc::*;fn main() {
let manager = ODBCConnectionManager::new("DSN=PostgreSQL");
let pool = r2d2::Pool::new(manager).unwrap();let mut children = vec![];
for i in 0..10i32 {
let pool = pool.clone();
children.push(thread::spawn(move || {
let pool_conn = pool.get().unwrap();
let conn = pool_conn.raw();
let stmt = Statement::with_parent(&conn).unwrap();
if let Data(mut stmt) = stmt.exec_direct("SELECT version()").unwrap() {
while let Some(mut cursor) = stmt.fetch().unwrap() {
if let Some(val) = cursor.get_data::<&str>(1).unwrap() {
println!("THREAD {} {}", i, val);
}
}
}
}));
}for child in children {
let _ = child.join();
}
}```