-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An example how to connect using named pipes
- Loading branch information
Julius de Bruijn
committed
Mar 1, 2021
1 parent
f9c702d
commit 1c1c765
Showing
2 changed files
with
29 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use tokio::net::windows::named_pipe::NamedPipe; | ||
use tiberius::{Config, AuthMethod, Client}; | ||
use tokio_util::compat::TokioAsyncWriteCompatExt; | ||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
let mut config = Config::new(); | ||
config.authentication(AuthMethod::Integrated); | ||
config.trust_cert(); | ||
|
||
let pipe = NamedPipe::connect("\\\\.\\pipe\\sql\\query").await?; | ||
let mut client = Client::connect(config, pipe.compat_write()).await?; | ||
|
||
let stream = client.query("SELECT @P1", &[&1i32]).await?; | ||
let row = stream.into_row().await?.unwrap(); | ||
|
||
println!("{:?}", row); | ||
assert_eq!(Some(1), row.get(0)); | ||
|
||
Ok(()) | ||
} |