- Notifications
You must be signed in to change notification settings - Fork27
The mssql_python module
Jahnvi Thakkar edited this pageSep 18, 2025 ·1 revision
This page documents theglobal attributes and functions available directly from themssql_python module. These apply across all connections and cursors created usingmssql_python.
| Attribute | Value | Description |
|---|---|---|
| apilevel | "2.0" | The DB API level supported (perPEP 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 butnot connections. |
| lowercase | False | IfTrue, column names returned from queries are automatically converted to lowercase. |
| decimal_separator | "." (default) | The character used when parsingNUMERIC/DECIMAL values. Initialized at import from locale, defaults to"." if unavailable. |
Returns the global settings object.
importmssql_pythonsettings=mssql_python.get_settings()print(settings.lowercase)# Falseprint(settings.decimal_separator)# "."
Sets the decimal separator character used when parsingNUMERIC/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.
importmssql_python# Change separator to commamssql_python.setDecimalSeparator(",")
Returns the current decimal separator.
importmssql_pythonsep=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.
importmssql_python# Enable pooling with defaultsmssql_python.pooling()# Enable pooling with custom valuesmssql_python.pooling(max_size=50,idle_timeout=300)# Disable poolingmssql_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_sizeandidle_timeoutto avoid resource exhaustion or stale connections in long-running applications.