Crate tiberius [] [src]

A pure-rust TDS implementation for Microsoft SQL Server (>=2008)

A simple example

Warning: Do not use simple_query with user-specified data. Resort to prepared statements for that.

extern crate futures;
extern crate tokio_core;
extern crate tiberius;
use futures::Future;
use tokio_core::reactor::Core;
use tiberius::SqlConnection;
use tiberius::stmt::ResultStreamExt;

fn main() {
   let mut lp = Core::new().unwrap();
   // for windows we demonstrate the hardcoded variant
   // which is equivalent to:
   //     let connection_string = "server=tcp:localhost,1433;integratedSecurity=true;";
   //     let future = SqlConnection::connect(lp.handle(), connection_string).and_then(|conn| {
   // and for linux we use the connection string from an environment variable
   let connection_string = if cfg!(windows) {
       "server=tcp:localhost,1433;integratedSecurity=true;".to_owned()
   } else {
       ::std::env::var("TIBERIUS_TEST_CONNECTION_STRING").unwrap()
   };

   let future = SqlConnection::connect(lp.handle(), connection_string.as_str()).and_then(|conn| {
       conn.simple_query("SELECT 1+2").for_each_row(|row| {
           let val: i32 = row.get(0);
           assert_eq!(val, 3i32);
           Ok(())
       })
   });
   lp.run(future).unwrap();
}

Modules

query

Query results and resultsets

stmt

Prepared statements

Structs

ConnectEndpoint

A target address and connection settings = all that's required to connect to a SQL server

ConnectParams

Settings for the connection, everything that isn't IO/transport specific (e.g. authentication)

SqlConnection

A connection to a SQL server with an underlying IO (e.g. socket)

Transaction

A transaction

Enums

AuthMethod

The authentication method that should be used during authentication

EncryptionLevel
SqlConnectionNew

A representation of the initialization state of an SQL connection (pending connection)

TdsError

A unified error enum that contains several errors that might occurr during the lifecycle of this driver

WinAuth

Traits

BoxableIo

A variant of Io which can be boxed to allow dynamic dispatch

StmtResult

A type which is constructable from a statement as a statement's result

ToConnectEndpoint

Something that's able to construct all that's required to connect to an endpoint

ToIo

Something that can be converted to an underlying IO

Type Definitions

TdsResult