Microsoft SQL Server Driver v1.4.1¶
Note
This project is not associated with Microsoft.
Driver Version v1.4.1 Tested With Microsoft SQL Server 2025
This driver provides access to Microsoft SQL Server .
Installation & Quickstart¶
The driver can be installed with dbc :
dbc install mssql
Connecting¶
To use the driver, provide a SQL Server connection string as the uri option. The driver supports URI format and DSN-style connection strings, but URIs are recommended.
from adbc_driver_manager import dbapi
dbapi.connect(
driver="mssql",
db_kwargs={
"uri": "mssql://sa:password@localhost:1433"
}
)
Note: The example above is for Python using the adbc-driver-manager package but the process will be similar for other driver managers. See adbc-quickstarts .
Connection String Format¶
SQL Server URI syntax:
mssql://[user:[password]]@host[:port][/instance][?param1=value¶m2=value]
sqlserver://[user:[password]]@host[:port][/instance][?param1=value¶m2=value]
This follows the format of Microsoft’s official Go MSSQL driver .
Components:
scheme:mssql://orsqlserver://(required) - both schemes are supporteduser/password: (optional) Credentials for standard SQL Server authentication.host: (required) The hostname or IP address of the SQL Server machine.port: (optional) Defaults to 1433.instance: (optional) The name of the SQL Server instance (e.g., SQLExpress).Query Parameters: Additional configuration options. For a list of common parameters, see the Microsoft’s official Go MSSQL driver
Note
Reserved characters in URI elements must be URI-encoded. For example, @ becomes %40.
Examples:
mssql://username:mypass@localhost?database=master&connection+timeout=30mssql://username:mypass@localhost:1234?database=master&connection+timeout=30mssql://username@localhost/SQLExpress?database=master&connection+timeout=30sqlserver://sa@localhost/SQLExpress?database=master&connection+timeout=30sqlserver://sa:mypass@localhost?database=master&connection+timeout=30sqlserver://sa:mypass@localhost:1234?database=master&connection+timeout=30
EntraID (Azure Active Directory) authentication is enabled by adding a fedauth parameter to your connection URI. For more information, see the documentation for Microsoft’s official Go MSSQL driver .
This driver also supports other types of connection strings that are supported by Microsoft’s official Go MSSQL driver .
Feature & Type Support¶
| Feature | Microsoft SQL Server | |
|---|---|---|
| Bulk Ingestion | Create | ✅ |
| Append | ✅ | |
| Create/Append | ✅ | |
| Replace | ✅ | |
| Temporary Table | ✅ | |
| Target Catalog | ✅ | |
| Target Schema | ✅ | |
| Non-nullable fields are marked NOT NULL | ✅ | |
| Catalog (GetObjects) | depth=catalogs | ✅ |
| depth=db_schemas | ✅ | |
| depth=tables | ✅ | |
| depth=columns (all) | ✅ | |
| Get Parameter Schema | ✅ | |
| Get Table Schema | ✅ | |
| Prepared Statements | ✅ | |
| Transactions | ✅ | |
Types¶
Database to Arrow¶
| Database Type | Microsoft SQL Server |
|---|---|
|
BIGINT |
int64 |
|
BIT |
bool |
|
CHAR |
string |
|
DATE |
date32[day] |
|
DATETIME |
timestamp[us] (with time zone) |
|
DATETIME2 |
timestamp[us] (with time zone) |
|
DECIMAL |
decimal128 |
|
DOUBLE PRECISION |
double |
|
GEOGRAPHY |
extension<geoarrow.wkb> |
|
GEOMETRY |
extension<geoarrow.wkb> |
|
IMAGE |
binary |
|
INT |
int32 |
|
MONEY |
decimal128 |
|
NCHAR |
string |
|
NTEXT |
string |
|
NTEXT (mssql.query.large_text_type = large_string) |
large_string |
|
NTEXT (mssql.query.large_text_type = string_view) |
string_view |
|
NUMERIC |
decimal128 |
|
NVARCHAR |
string |
|
REAL |
float |
|
SMALLDATETIME |
timestamp[us] (with time zone) |
|
SMALLINT |
int16 |
|
SMALLMONEY |
decimal128 |
|
TEXT |
string |
|
TEXT (mssql.query.large_text_type = large_string) |
large_string |
|
TEXT (mssql.query.large_text_type = string_view) |
string_view |
|
TIME |
time64[ns] ⚠️ [1] |
|
TIME(0) |
time32[s] |
|
TIME(1) |
time32[ms] |
|
TIME(2) |
time32[ms] |
|
TIME(3) |
time32[ms] |
|
TIME(4) |
time64[us] |
|
TIME(5) |
time64[us] |
|
TIME(6) |
time64[us] |
|
TIME(7) |
time64[ns] |
|
TINYINT |
uint8 |
|
UNIQUEIDENTIFIER |
extension<arrow.uuid> |
|
VARBINARY |
binary |
|
VARCHAR |
string |
|
XML |
string |
Arrow to Database¶
| Arrow Type | Microsoft SQL Server Type | |
|---|---|---|
| Bind | Ingest | |
|
binary |
VARBINARY |
VARBINARY(MAX) |
|
binary_view |
VARBINARY |
VARBINARY(MAX) |
|
bool |
BIT |
|
|
date32[day] |
DATE |
|
|
decimal128 |
DECIMAL(10,2) |
NUMERIC |
|
double |
DOUBLE PRECISION |
|
|
extension<geoarrow.wkb> |
(NA/not tested) |
GEOGRAPHY, GEOMETRY |
|
fixed_size_binary |
VARBINARY |
VARBINARY(MAX) |
|
float |
REAL |
|
|
halffloat |
REAL |
(NA/not tested) |
|
int16 |
SMALLINT |
|
|
int32 |
INT |
|
|
int64 |
BIGINT |
|
|
large_binary |
VARBINARY |
VARBINARY(MAX) |
|
large_string |
NVARCHAR |
NVARCHAR(MAX) |
|
string |
NVARCHAR |
NVARCHAR(MAX) |
|
string_view |
NVARCHAR |
NVARCHAR(MAX) |
|
time32[ms] |
TIME(3), TIME(2), TIME, TIME(1) |
TIME(7) ⚠️ [3] |
|
time32[s] |
TIME, TIME(0) |
TIME(7) ⚠️ [3] |
|
time64[ns] |
TIME, TIME(7) |
TIME(7) ⚠️ [3] |
|
time64[us] |
TIME(6), TIME(5), TIME(4), TIME |
TIME(7) ⚠️ [3] |
|
timestamp[ms] |
DATETIME2 |
|
|
timestamp[ms] (with time zone) |
DATETIME2 |
|
|
timestamp[ns] |
DATETIME2 [2] |
DATETIME2 |
|
timestamp[ns] (with time zone) |
DATETIME2 [2] |
DATETIME2 |
|
timestamp[s] |
DATETIME2 |
|
|
timestamp[s] (with time zone) |
DATETIME2 |
|
|
timestamp[us] |
DATETIME2 |
|
|
timestamp[us] (with time zone) |
DATETIME2 |
|
Options¶
Options Affecting Queries¶
mssql.query.large_text_type
: Values: string, string_view, or large_string. Default: string
Determines the Arrow string type to use for VARCHAR(MAX) and
NVARCHAR(MAX) (and their deprecated aliases TEXT and NTEXT) columns.
This does not affect bulk ingest.
Compatibility¶
This driver was tested on:
Microsoft SQL Server
17.0.4045.5 Enterprise Evaluation Edition (64-bit)
Previous Versions¶
To see documentation for previous versions of this driver, see the following: