[][src]Struct odbc::Environment

pub struct Environment<V> { /* fields omitted */ }

Handle to an ODBC Environment

Creating an instance of this type is the first thing you do then using ODBC. The environment must outlive all connections created with it.

Methods

impl Environment<Version3>[src]

pub fn drivers(&mut self) -> Result<Vec<DriverInfo>>[src]

Stores all driver description and attributes in a Vec

pub fn data_sources(&mut self) -> Result<Vec<DataSourceInfo>>[src]

Stores all data source server names and descriptions in a Vec

pub fn system_data_sources(&mut self) -> Result<Vec<DataSourceInfo>>[src]

Stores all system data source server names and descriptions in a Vec

pub fn user_data_sources(&mut self) -> Result<Vec<DataSourceInfo>>[src]

Stores all user data source server names and descriptions in a Vec

impl<V: Version> Environment<V>[src]

pub fn new() -> Result<Environment<V>, Option<DiagnosticRecord>>[src]

Creates an ODBC Environment and declares specification of V are used. You can use the shorthand create_environment_v3() instead.

Example

use odbc::*;
fn do_database_stuff() -> std::result::Result<(), Option<DiagnosticRecord>> {
    let env : Environment<Version3> = Environment::new()?; // first thing to do
    // ...
    Ok(())
}

Return

While most functions in this crate return a DiagnosticRecord in the event of an Error the creation of an environment is special. Since DiagnosticRecords are created using the environment, at least its allocation has to be successful to obtain one. If the allocation fails it is sadly not possible to receive further Diagnostics. Setting an unsupported version may however result in an ordinary Some(DiagnosticRecord).

impl Environment<Version3>[src]

pub fn connect<'env>(
    &'env self,
    dsn: &str,
    usr: &str,
    pwd: &str
) -> Result<Connection<'env, AutocommitOn>>
[src]

Connects to an ODBC data source

Arguments

  • dsn - Data source name configured in the odbc.ini file
  • usr - User identifier
  • pwd - Authentication (usually password)

pub fn connect_with_connection_string<'env>(
    &'env self,
    connection_str: &str
) -> Result<Connection<'env, AutocommitOn>>
[src]

Connects to an ODBC data source using a connection string

See [SQLDriverConnect][1] for the syntax. [1]: https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqldriverconnect-function

Trait Implementations

impl<V> Handle for Environment<V>[src]

type To = Env

impl<V: Debug> Debug for Environment<V>[src]

impl<V> Handle for Environment<V>[src]

Auto Trait Implementations

impl<V> !Send for Environment<V>

impl<V> !Sync for Environment<V>

impl<V> Unpin for Environment<V> where
    V: Unpin

impl<V> UnwindSafe for Environment<V> where
    V: UnwindSafe

impl<V> RefUnwindSafe for Environment<V> where
    V: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<H> Diagnostics for H where
    H: Handle
[src]