forked from microsoft/mssql-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
78 lines (67 loc) · 1.65 KB
/
__init__.py
File metadata and controls
78 lines (67 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
This module initializes the mssql_python package.
"""
# Exceptions
# https://www.python.org/dev/peps/pep-0249/#exceptions
from .exceptions import (
Warning,
Error,
InterfaceError,
DatabaseError,
DataError,
OperationalError,
IntegrityError,
InternalError,
ProgrammingError,
NotSupportedError,
)
# Type Objects
from .type import (
Date,
Time,
Timestamp,
DateFromTicks,
TimeFromTicks,
TimestampFromTicks,
Binary,
STRING,
BINARY,
NUMBER,
DATETIME,
ROWID,
)
# Connection Objects
from .db_connection import connect, Connection
# Cursor Objects
from .cursor import Cursor
# Logging Configuration
from .logging_config import setup_logging, get_logger
# Constants
from .constants import ConstantsDDBC
# Export specific constants for setencoding()
SQL_CHAR = ConstantsDDBC.SQL_CHAR.value
SQL_WCHAR = ConstantsDDBC.SQL_WCHAR.value
SQL_WMETADATA = -99
# GLOBALS
# Read-Only
apilevel = "2.0"
paramstyle = "qmark"
threadsafety = 1
from .pooling import PoolingManager
def pooling(max_size=100, idle_timeout=600, enabled=True):
# """
# Enable connection pooling with the specified parameters.
# By default:
# - If not explicitly called, pooling will be auto-enabled with default values.
# Args:
# max_size (int): Maximum number of connections in the pool.
# idle_timeout (int): Time in seconds before idle connections are closed.
# Returns:
# None
# """
if not enabled:
PoolingManager.disable()
else:
PoolingManager.enable(max_size, idle_timeout)