-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from fernandobatels/connstr
Connection string support
- Loading branch information
Showing
13 changed files
with
899 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,16 @@ let mut conn = rsfbclient::builder_native() | |
.connect()? | ||
``` | ||
|
||
You also can choose a string connection configuration | ||
```rust | ||
// Using the native Firebird client | ||
rsfbclient::builder_native() | ||
.from_string("firebird://SYSDBA:[email protected]:3050/awesome.fdb?charset=ascii") | ||
// Or using the pure rust implementation | ||
rsfbclient::builder_pure_rust() | ||
.from_string("firebird://SYSDBA:[email protected]:3050/awesome.fdb?charset=ascii") | ||
``` | ||
|
||
3. Now you can use the lib | ||
```rust | ||
let rows = conn.query_iter("select col_a, col_b, col_c from test", ())?; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//! | ||
//! Rust Firebird Client | ||
//! | ||
//! Example of string connection configuration | ||
//! | ||
//! How to use: `DATABASE_URL=firebird://SYSDBA:masterkey@localhost:3050/test.fdb?charset=ascii cargo run --example string_conn` | ||
#![allow(unused_variables, unused_mut)] | ||
|
||
use rsfbclient::{prelude::*, FbError}; | ||
use std::env; | ||
|
||
fn main() -> Result<(), FbError> { | ||
let string_conf = | ||
env::var("DATABASE_URL").map_err(|e| FbError::from("DATABASE_URL env var is empty"))?; | ||
|
||
#[cfg(feature = "native_client")] | ||
let mut conn = rsfbclient::builder_native() | ||
.from_string(&string_conf)? | ||
.connect()?; | ||
|
||
#[cfg(feature = "pure_rust")] | ||
let mut conn = rsfbclient::builder_pure_rust() | ||
.from_string(&string_conf)? | ||
.connect()?; | ||
|
||
let rows = conn.query_iter("SELECT a.RDB$RELATION_NAME FROM RDB$RELATIONS a WHERE COALESCE(RDB$SYSTEM_FLAG, 0) = 0 AND RDB$RELATION_TYPE = 0", ())?; | ||
|
||
println!("-------------"); | ||
println!("Table name"); | ||
println!("-------------"); | ||
|
||
for row in rows { | ||
let (r_name,): (String,) = row?; | ||
|
||
println!("{:^10}", r_name); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.