pub struct MssqlConnection { /* private fields */ }Expand description
MSSQL connection backed by an actor thread that owns the ODBC connection.
Implementations§
Source§impl MssqlConnection
impl MssqlConnection
Sourcepub fn connect_blocking(options: &MssqlConnectOptions) -> Result<Self>
pub fn connect_blocking(options: &MssqlConnectOptions) -> Result<Self>
Opens a blocking MSSQL ODBC connection with the provided options and spawns an actor thread to own it.
Sourcepub fn ping_blocking(&self) -> Result<(), Error>
pub fn ping_blocking(&self) -> Result<(), Error>
Executes a minimal connectivity query.
Sourcepub fn dbms_name(&self) -> Result<String, Error>
pub fn dbms_name(&self) -> Result<String, Error>
Returns the DBMS name reported by the ODBC driver.
Sourcepub fn prepare_blocking(&self, sql: SqlStr) -> Result<MssqlStatement, Error>
pub fn prepare_blocking(&self, sql: SqlStr) -> Result<MssqlStatement, Error>
Prepares a statement and returns the metadata reported by the ODBC driver.
Trait Implementations§
Source§impl<'c> Acquire<'c> for &'c mut MssqlConnection
impl<'c> Acquire<'c> for &'c mut MssqlConnection
Source§impl AnyConnectionBackend for MssqlConnection
Available on crate feature any only.
impl AnyConnectionBackend for MssqlConnection
any only.Source§fn close(self: Box<Self>) -> BoxFuture<'static, Result<()>>
fn close(self: Box<Self>) -> BoxFuture<'static, Result<()>>
Source§fn ping(&mut self) -> BoxFuture<'_, Result<()>>
fn ping(&mut self) -> BoxFuture<'_, Result<()>>
Source§fn begin(&mut self, statement: Option<SqlStr>) -> BoxFuture<'_, Result<()>>
fn begin(&mut self, statement: Option<SqlStr>) -> BoxFuture<'_, Result<()>>
fn commit(&mut self) -> BoxFuture<'_, Result<()>>
fn rollback(&mut self) -> BoxFuture<'_, Result<()>>
fn start_rollback(&mut self)
Source§fn get_transaction_depth(&self) -> usize
fn get_transaction_depth(&self) -> usize
Source§fn shrink_buffers(&mut self)
fn shrink_buffers(&mut self)
Connection::shrink_buffers().Source§fn cached_statements_size(&self) -> usize
fn cached_statements_size(&self) -> usize
Source§fn clear_cached_statements(&mut self) -> BoxFuture<'_, Result<()>>
fn clear_cached_statements(&mut self) -> BoxFuture<'_, Result<()>>
Source§fn as_migrate(&mut self) -> Result<&mut (dyn Migrate + Send + 'static)>
fn as_migrate(&mut self) -> Result<&mut (dyn Migrate + Send + 'static)>
migrate only.fn fetch_many( &mut self, query: SqlStr, persistent: bool, arguments: Option<AnyArguments>, ) -> BoxStream<'_, Result<Either<AnyQueryResult, AnyRow>>>
fn fetch_optional( &mut self, query: SqlStr, persistent: bool, arguments: Option<AnyArguments>, ) -> BoxFuture<'_, Result<Option<AnyRow>>>
fn prepare_with<'c, 'q: 'c>( &'c mut self, sql: SqlStr, _parameters: &[AnyTypeInfo], ) -> BoxFuture<'c, Result<AnyStatement>>
Source§fn describe(&mut self, sql: SqlStr) -> BoxFuture<'_, Result<Describe<Any>>>
fn describe(&mut self, sql: SqlStr) -> BoxFuture<'_, Result<Describe<Any>>>
offline only.Source§fn is_in_transaction(&self) -> bool
fn is_in_transaction(&self) -> bool
Source§impl Connection for MssqlConnection
impl Connection for MssqlConnection
type Database = Mssql
type Options = MssqlConnectOptions
Source§async fn close(self) -> Result<(), Error>
async fn close(self) -> Result<(), Error>
Source§async fn ping(&mut self) -> Result<(), Error>
async fn ping(&mut self) -> Result<(), Error>
Source§fn begin(
&mut self,
) -> impl Future<Output = Result<Transaction<'_, Self::Database>, Error>> + Send + '_
fn begin( &mut self, ) -> impl Future<Output = Result<Transaction<'_, Self::Database>, Error>> + Send + '_
Source§fn shrink_buffers(&mut self)
fn shrink_buffers(&mut self)
Source§fn cached_statements_size(&self) -> usizewhere
Self::Database: HasStatementCache,
fn cached_statements_size(&self) -> usizewhere
Self::Database: HasStatementCache,
Source§async fn clear_cached_statements(&mut self) -> Result<(), Error>where
Self::Database: HasStatementCache,
async fn clear_cached_statements(&mut self) -> Result<(), Error>where
Self::Database: HasStatementCache,
Source§fn begin_with(
&mut self,
statement: impl SqlSafeStr,
) -> impl Future<Output = Result<Transaction<'_, Self::Database>, Error>> + Sendwhere
Self: Sized,
fn begin_with(
&mut self,
statement: impl SqlSafeStr,
) -> impl Future<Output = Result<Transaction<'_, Self::Database>, Error>> + Sendwhere
Self: Sized,
Source§fn is_in_transaction(&self) -> bool
fn is_in_transaction(&self) -> bool
true if the connection is currently in a transaction. Read moreSource§fn transaction<'a, F, R, E>(
&'a mut self,
callback: F,
) -> impl Future<Output = Result<R, E>> + Send + 'a
fn transaction<'a, F, R, E>( &'a mut self, callback: F, ) -> impl Future<Output = Result<R, E>> + Send + 'a
Source§impl Debug for MssqlConnection
impl Debug for MssqlConnection
Source§impl Drop for MssqlConnection
impl Drop for MssqlConnection
Source§impl<'c> Executor<'c> for &'c mut MssqlConnection
impl<'c> Executor<'c> for &'c mut MssqlConnection
type Database = Mssql
Source§fn fetch_many<'e, 'q, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<MssqlQueryResult, MssqlRow>, Error>>
fn fetch_many<'e, 'q, E>( self, query: E, ) -> BoxStream<'e, Result<Either<MssqlQueryResult, MssqlRow>, Error>>
Source§fn fetch_optional<'e, 'q, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<MssqlRow>, Error>>
fn fetch_optional<'e, 'q, E>( self, query: E, ) -> BoxFuture<'e, Result<Option<MssqlRow>, Error>>
Source§fn prepare_with<'e>(
self,
sql: SqlStr,
_parameters: &[MssqlTypeInfo],
) -> BoxFuture<'e, Result<MssqlStatement, Error>>where
'c: 'e,
fn prepare_with<'e>(
self,
sql: SqlStr,
_parameters: &[MssqlTypeInfo],
) -> BoxFuture<'e, Result<MssqlStatement, Error>>where
'c: 'e,
Source§fn execute<'e, 'q, E>(
self,
query: E,
) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
fn execute<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Future<Output = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
Source§fn execute_many<'e, 'q, E>(
self,
query: E,
) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
fn execute_many<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
Source§fn fetch<'e, 'q, E>(
self,
query: E,
) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Row, Error>> + Send + 'e>>
fn fetch<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::Row, Error>> + Send + 'e>>
Source§fn fetch_all<'e, 'q, E>(
self,
query: E,
) -> Pin<Box<dyn Future<Output = Result<Vec<<Self::Database as Database>::Row>, Error>> + Send + 'e>>
fn fetch_all<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Future<Output = Result<Vec<<Self::Database as Database>::Row>, Error>> + Send + 'e>>
Vec.Source§impl Migrate for MssqlConnection
Available on crate feature migrate only.
impl Migrate for MssqlConnection
migrate only.Source§fn create_schema_if_not_exists<'e>(
&'e mut self,
schema_name: &'e str,
) -> BoxFuture<'e, Result<(), MigrateError>>
fn create_schema_if_not_exists<'e>( &'e mut self, schema_name: &'e str, ) -> BoxFuture<'e, Result<(), MigrateError>>
MSSQL does not support CREATE SCHEMA IF NOT EXISTS as a single
statement, so we use a conditional T-SQL block.
Source§fn ensure_migrations_table<'e>(
&'e mut self,
table_name: &'e str,
) -> BoxFuture<'e, Result<(), MigrateError>>
fn ensure_migrations_table<'e>( &'e mut self, table_name: &'e str, ) -> BoxFuture<'e, Result<(), MigrateError>>
Creates the migrations tracking table if it does not yet exist.
Source§fn dirty_version<'e>(
&'e mut self,
_table_name: &'e str,
) -> BoxFuture<'e, Result<Option<i64>, MigrateError>>
fn dirty_version<'e>( &'e mut self, _table_name: &'e str, ) -> BoxFuture<'e, Result<Option<i64>, MigrateError>>
MSSQL supports transactional DDL, so a dirty (partially applied)
migration cannot occur. Always returns None.
Source§fn list_applied_migrations<'e>(
&'e mut self,
table_name: &'e str,
) -> BoxFuture<'e, Result<Vec<AppliedMigration>, MigrateError>>
fn list_applied_migrations<'e>( &'e mut self, table_name: &'e str, ) -> BoxFuture<'e, Result<Vec<AppliedMigration>, MigrateError>>
Lists all previously applied migrations, ordered by version.
Source§fn lock(&mut self) -> BoxFuture<'_, Result<(), MigrateError>>
fn lock(&mut self) -> BoxFuture<'_, Result<(), MigrateError>>
Acquires an exclusive application-level lock using sp_getapplock.
Source§fn unlock(&mut self) -> BoxFuture<'_, Result<(), MigrateError>>
fn unlock(&mut self) -> BoxFuture<'_, Result<(), MigrateError>>
Releases the application-level lock using sp_releaseapplock.
Source§fn apply<'e>(
&'e mut self,
_table_name: &'e str,
migration: &'e Migration,
) -> BoxFuture<'e, Result<Duration, MigrateError>>
fn apply<'e>( &'e mut self, _table_name: &'e str, migration: &'e Migration, ) -> BoxFuture<'e, Result<Duration, MigrateError>>
Applies a migration: executes the SQL, then records the migration in the tracking table.
Auto Trait Implementations§
impl !Freeze for MssqlConnection
impl RefUnwindSafe for MssqlConnection
impl Send for MssqlConnection
impl Sync for MssqlConnection
impl Unpin for MssqlConnection
impl UnsafeUnpin for MssqlConnection
impl UnwindSafe for MssqlConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more