Skip to content

MSSQL guide

The MSSQL ADBC driver is distributed via the ADBC Driver Foundry, not PyPI. Follow the Foundry installation guide to install it before using MSSQLConfig.

adbc-poolhouse does not need a separate extra for MSSQL:

pip install adbc-poolhouse

Connection

MSSQLConfig covers Microsoft SQL Server, Azure SQL Database, Azure SQL Managed Instance, Azure Synapse Analytics, and Azure Fabric SQL endpoint.

URI mode

from adbc_poolhouse import MSSQLConfig, create_pool

config = MSSQLConfig(
    uri="sqlserver://me:s3cret@myserver.database.windows.net:1433?database=mydb",  # pragma: allowlist secret
)
pool = create_pool(config)

Individual fields

from adbc_poolhouse import MSSQLConfig, create_pool

config = MSSQLConfig(
    host="myserver.database.windows.net",
    user="me",
    password="s3cret",  # pragma: allowlist secret
    database="mydb",
)
pool = create_pool(config)

Loading from environment variables

MSSQLConfig reads all fields from environment variables with the MSSQL_ prefix:

export MSSQL_HOST=myserver.database.windows.net
export MSSQL_USER=me
export MSSQL_PASSWORD=s3cret  # pragma: allowlist secret
export MSSQL_DATABASE=mydb
from adbc_poolhouse import MSSQLConfig, create_pool

config = MSSQLConfig()  # reads from env
pool = create_pool(config)

See also