Installation
Prerequisites
Microsoft ODBC Driver 18 for SQL Server must be installed on the target system:
sh
# Windows
winget install Microsoft.ODBC.18
# macOS
brew install microsoft/mssql-release/msodbcsql18
# Debian / Ubuntu
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
sudo apt-get update && sudo apt-get install -y msodbcsql18
# RHEL / Fedora
sudo dnf install msodbcsql18Install the Package
sh
# Deno
deno add jsr:@tsdrivers/mssql
# Node.js
npm install @tsdrivers/mssql koffi
# Bun
bun add @tsdrivers/mssql koffiThe @tsdrivers/mssql package auto-detects your runtime and uses the correct FFI adapter automatically. Deno uses its built-in Deno.dlopen; Node.js and Bun use koffi which provides nonblocking async FFI calls via worker threads.
Native Library
The native Rust library must be available at runtime. There are several ways to provide it:
Automatic Download
The Node.js and Bun postinstall script downloads the native library automatically. For Deno, use the install script:
sh
deno run -A jsr:@tsdrivers/mssql/installManual Download
Download the appropriate binary from GitHub Releases and place it in one of the search paths.
Environment Variable
Set TSDRIVERS_MSSQL_LIB_PATH to the full path of the native library:
sh
export TSDRIVERS_MSSQL_LIB_PATH=/path/to/mssqlts-linux-x86_64.soLibrary Search Order
The library resolver searches these locations in order:
TSDRIVERS_MSSQL_LIB_PATHenvironment variablenode_modules/@tsdrivers/mssql/native/- Current directory and parent directories (including
lib/,.lib/,bin/,.bin/subdirs) - Next to the entry point script
- Home directory (
~/lib/,~/.lib/,~/bin/,~/.bin/) - Cache directory (
~/.cache/@tsdrivers/mssql/{version}/)
Platform Binaries
| Platform | Architecture | Filename |
|---|---|---|
| Linux | x86_64 | mssqlts-linux-x86_64.so |
| Linux | aarch64 | mssqlts-linux-aarch64.so |
| macOS | x86_64 | mssqlts-macos-x86_64.dylib |
| macOS | aarch64 | mssqlts-macos-aarch64.dylib |
| Windows | x86_64 | mssqlts-windows-x86_64.dll |
| Windows | aarch64 | mssqlts-windows-aarch64.dll |
Build from Source
sh
cd projects/rust-odbc-mssql
cargo build --release
# Copy projects/rust-odbc-mssql/target/release/libmssqlts.so to your project