Skip to main content

Crate sqlx_mssql_odbc_core

Crate sqlx_mssql_odbc_core 

Source
Expand description

MSSQL driver for SQLx via ODBC.

sqlx-mssql-odbc connects SQLx to Microsoft SQL Server through an ODBC driver manager (unixODBC on Linux/macOS, built-in on Windows).

§Connection

use sqlx_core::connection::Connection;
use sqlx_core::row::Row;
use sqlx_mssql_odbc_core::MssqlConnection;

let mut conn = MssqlConnection::connect("mssql://sa:Password1!@localhost:1433/testdb").await?;

let row = sqlx_core::query::query("SELECT 1")
    .fetch_one(&mut conn)
    .await?;

let value: i32 = row.try_get(0)?;
assert_eq!(value, 1);

conn.close().await?;

MssqlConnection::connect() accepts a standard mssql:// URL or a raw ODBC connection string.

§Requirements

On Linux and macOS, install the unixODBC driver manager and the Microsoft ODBC Driver 17 or 18 for SQL Server. On Windows, the driver manager is built in, but the Microsoft ODBC Driver for SQL Server still needs to be installed.

Enable the vendored-unix-odbc feature to statically link the unixODBC driver manager into your application on Linux or macOS.

Buffered fetching can improve throughput, but long text or binary values may be truncated when max_column_size is set. Use unbuffered mode for values that may exceed that limit.

Modules§

type_checking
Type-checking support for compile-time query macros.

Structs§

Mssql
MSSQL database marker for SQLx-core traits.
MssqlArguments
Values that can be bound to MSSQL ODBC parameters.
MssqlBufferSettings
Fetch-buffer settings used by the MSSQL ODBC driver.
MssqlColumn
Column metadata for an MSSQL result set via ODBC.
MssqlConnectOptions
Connection options for an MSSQL ODBC data source.
MssqlConnection
MSSQL connection backed by an actor thread that owns the ODBC connection.
MssqlDatabaseError
Database error details extracted from ODBC diagnostics.
MssqlParameterCollection
Owned MSSQL ODBC parameter storage ready to bind with odbc-api.
MssqlQueryResult
Result summary for an MSSQL query via ODBC.
MssqlRow
Minimal MSSQL row container used by the SQLx-core skeleton.
MssqlStatement
Prepared statement metadata for MSSQL via ODBC.
MssqlTransactionManager
Transaction manager for MSSQL via ODBC.
MssqlTypeInfo
Type information for an MSSQL ODBC value.
MssqlValue
A small owned MSSQL ODBC value representation.

Enums§

MssqlArgumentValue
Values that can currently be bound to MSSQL ODBC parameters.
MssqlError
Error type returned by this crate.
MssqlValueKind
Supported owned MSSQL ODBC value kinds.

Traits§

DataTypeExt
Helper predicates for odbc-api data type groups.
MssqlExecutor
An alias for Executor<'_, Database = Mssql>.

Type Aliases§

MssqlPool
An alias for Pool, specialized for MSSQL.
MssqlPoolOptions
An alias for PoolOptions, specialized for MSSQL.
MssqlTransaction
An alias for Transaction, specialized for MSSQL.
Result
Result alias for this crate.