Skip to main content

SqlServerConnection

Struct SqlServerConnection 

Source
pub struct SqlServerConnection { /* private fields */ }

Implementations§

Source§

impl SqlServerConnection

Source

pub async fn connect(config: &DatabaseConfig) -> Result<SqlServerConnection>

Open a connection: pre-login, encryption, then login.

Source

pub async fn connect_with( config: &DatabaseConfig, options: SqlServerOptions, ) -> Result<SqlServerConnection>

Source

pub fn is_broken(&self) -> bool

Source

pub fn in_transaction(&self) -> bool

True while a transaction is open, so the pool never hands back a connection that would leak one.

Source

pub async fn simple_query(&mut self, sql: &str) -> Result<QueryResult>

Run a statement with no parameters, as a batch.

Used for DDL and for transaction control, both of which have to run outside sp_executesql — a begin transaction inside a procedure ends when the procedure does.

Source

pub async fn query( &mut self, sql: &str, params: &[Value], ) -> Result<QueryResult>

Run a statement through sp_executesql.

Every statement takes this route, parameters or not, because it is the route where a bound value is a value: the statement text and the parameter declarations are themselves arguments to a stored procedure, so nothing a caller binds is ever concatenated into SQL. A value cannot change the shape of a statement it was never part of.

Source

pub async fn close(self)

Hang up.

TDS has no goodbye token — MS-TDS says a client ends a session by closing the transport — so there is nothing to send first.

Trait Implementations§

Source§

impl DriverConnection for SqlServerConnection

Source§

fn query<'a>( &'a mut self, sql: &'a str, params: &'a [Value], ) -> BoxFuture<'a, Result<QueryResult>>

Run a statement with bound parameters. Read more
Source§

fn simple_query<'a>( &'a mut self, sql: &'a str, ) -> BoxFuture<'a, Result<QueryResult>>

Run a statement with no parameters — DDL, and transaction control.
Source§

fn is_broken(&self) -> bool

Whether this connection is known to be unusable, so the pool discards it instead of handing it to the next caller.
Source§

fn in_transaction(&self) -> bool

Whether a transaction is still open. A connection left inside one must never go back into rotation.
Source§

fn close(self: Box<Self>) -> BoxFuture<'static, ()>

Say goodbye politely, then hang up.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.