-
Notifications
You must be signed in to change notification settings - Fork 25
The mssql_python module
Jahnvi Thakkar edited this page Sep 18, 2025
·
1 revision
This page documents the global attributes and functions available directly from the mssql_python
module. These apply across all connections and cursors created using mssql_python
.
Attribute | Value | Description |
---|---|---|
apilevel | "2.0" |
The DB API level supported (per PEP 249). |
paramstyle | "qmark" |
The parameter style used in SQL queries (e.g., SELECT * FROM T WHERE id = ? ). |
threadsafety | 1 |
Indicates that threads may share the module but not connections. |
lowercase | False |
If True , column names returned from queries are automatically converted to lowercase. |
decimal_separator |
"." (default) |
The character used when parsing NUMERIC /DECIMAL values. Initialized at import from locale, defaults to "." if unavailable. |
Returns the global settings object.
import mssql_python
settings = mssql_python.get_settings()
print(settings.lowercase) # False
print(settings.decimal_separator) # "."
Sets the decimal separator character used when parsing NUMERIC/DECIMAL
values.
Args
-
separator (str)
: Must be a single non-whitespace, non-control character string.
Raises
-
ValueError
: If the input is empty, longer than one character, whitespace, or a control character.
import mssql_python
# Change separator to comma
mssql_python.setDecimalSeparator(",")
Returns the current decimal separator.
import mssql_python
sep = mssql_python.getDecimalSeparator()
print(sep) # "."
Configures the connection pooling behavior.
Args
-
max_size (int)
: Maximum number of connections in the pool. -
idle_timeout (int)
: Seconds before idle connections are closed. -
enabled (bool)
: Enable (True
) or disable (False
) pooling.
import mssql_python
# Enable pooling with defaults
mssql_python.pooling()
# Enable pooling with custom values
mssql_python.pooling(max_size=50, idle_timeout=300)
# Disable pooling
mssql_python.pooling(enabled=False)
⚠️ Security & Usage Notes
- Be careful when changing the
decimal separator
: setting it incorrectly may cause numeric parsing issues or inconsistent behavior across environments.- When enabling
connection pooling
, ensure proper sizing ofmax_size
andidle_timeout
to avoid resource exhaustion or stale connections in long-running applications.