pymssql Adapter¶
from sqlspec.adapters.pymssql import (
PymssqlConfig,
PymssqlConnectionParams,
PymssqlConnectionPool,
PymssqlDriver,
PymssqlDriverFeatures,
PymssqlExceptionHandler,
PymssqlPoolParams,
)
Synchronous Microsoft SQL Server adapter built on pymssql (FreeTDS). Inherited execution methods are documented on SyncDriverAdapterBase. See the SQL Server Setup Guide for usage examples.
Configuration & Parameters¶
PymssqlConfig
¶
Bases: SyncDatabaseConfig[PymssqlConnection, PymssqlConnectionPool, PymssqlDriver]
Configuration for pymssql synchronous connections.
PymssqlConnectionParams
¶
Bases: TypedDict
pymssql connection parameters.
Attributes:
| Name | Type | Description |
|---|---|---|
server |
NotRequired[str]
|
SQL Server hostname, |
host |
NotRequired[str]
|
Alias for |
user |
NotRequired[str]
|
SQL Server or Windows domain login ( |
password |
NotRequired[str]
|
Password for |
database |
NotRequired[str]
|
Initial SQL Server database selected on connect. |
port |
NotRequired[int | str]
|
SQL Server TCP port (defaults to |
timeout |
NotRequired[PymssqlTimeout]
|
Query response timeout in seconds ( |
login_timeout |
NotRequired[PymssqlTimeout]
|
Connection and authentication timeout in seconds (defaults to |
charset |
NotRequired[str]
|
Character encoding communicated over FreeTDS (defaults to |
as_dict |
NotRequired[bool]
|
Return rows from raw |
appname |
NotRequired[str]
|
Application name visible in |
conn_properties |
NotRequired[str]
|
Semicolon-separated |
autocommit |
NotRequired[bool]
|
Enable autocommit mode on new |
tds_version |
NotRequired[str]
|
Explicit FreeTDS protocol version (such as |
encryption |
NotRequired[Literal['off', 'request', 'require']]
|
FreeTDS TLS transport encryption requirement ( |
use_datetime2 |
NotRequired[bool]
|
Bind Python |
arraysize |
NotRequired[int]
|
Default row batch count returned by |
conv |
NotRequired[Mapping[int | type[Any], Callable[..., Any]]]
|
Custom FreeTDS type serialization/deserialization mapping. |
read_only |
NotRequired[bool]
|
Set Always On |
pool_recycle_seconds |
NotRequired[int]
|
Maximum connection age in seconds before |
health_check_interval |
NotRequired[float]
|
Minimum interval in seconds between connection health checks in |
extra |
NotRequired[dict[str, Any]]
|
Additional keyword arguments forwarded to |
PymssqlPoolParams
¶
PymssqlDriverFeatures
¶
Bases: TypedDict
Optional pymssql driver feature flags for JSON serialization, connection hooks, and events.
Attributes:
| Name | Type | Description |
|---|---|---|
json_serializer |
NotRequired[Callable[[Any], str]]
|
Custom JSON serializer applied to bound JSON parameters (defaults to |
json_deserializer |
NotRequired[Callable[[str], Any]]
|
Custom JSON deserializer applied to JSON result columns (defaults to |
on_connection_create |
NotRequired[Callable[[PymssqlConnection], None]]
|
Synchronous hook invoked with each raw |
enable_events |
NotRequired[bool]
|
Enable durable table-backed SQLSpec event queue support. |
events_backend |
NotRequired[Literal['poll_queue']]
|
Event channel backend ( |
Driver & Pool¶
PymssqlDriver
¶
PymssqlExceptionHandler
¶
PymssqlConnectionPool
¶
Thread-local connection manager for pymssql.
Extension Stores¶
PymssqlStore
¶
Bases: BaseSQLSpecStore['PymssqlConfig']
SQL Server-backed session store using pymssql sync sessions.