mssql-python 1.0.0__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. mssql_python/__init__.py +307 -0
  2. mssql_python/auth.py +222 -0
  3. mssql_python/connection.py +1493 -0
  4. mssql_python/connection_string_builder.py +113 -0
  5. mssql_python/connection_string_parser.py +381 -0
  6. mssql_python/constants.py +509 -0
  7. mssql_python/cursor.py +2601 -0
  8. mssql_python/db_connection.py +53 -0
  9. mssql_python/ddbc_bindings.cp314-amd64.pyd +0 -0
  10. mssql_python/ddbc_bindings.py +137 -0
  11. mssql_python/exceptions.py +574 -0
  12. mssql_python/helpers.py +357 -0
  13. mssql_python/libs/LICENSING +19 -0
  14. mssql_python/libs/linux/alpine/arm64/lib/MICROSOFT_ODBC_DRIVER_FOR_SQL_SERVER_LICENSE.txt +76 -0
  15. mssql_python/libs/linux/alpine/arm64/lib/libmsodbcsql-18.5.so.1.1 +0 -0
  16. mssql_python/libs/linux/alpine/arm64/lib/libodbcinst.so.2 +0 -0
  17. mssql_python/libs/linux/alpine/arm64/share/resources/en_US/msodbcsqlr18.rll +0 -0
  18. mssql_python/libs/linux/alpine/x86_64/lib/MICROSOFT_ODBC_DRIVER_FOR_SQL_SERVER_LICENSE.txt +76 -0
  19. mssql_python/libs/linux/alpine/x86_64/lib/libmsodbcsql-18.5.so.1.1 +0 -0
  20. mssql_python/libs/linux/alpine/x86_64/lib/libodbcinst.so.2 +0 -0
  21. mssql_python/libs/linux/alpine/x86_64/share/resources/en_US/msodbcsqlr18.rll +0 -0
  22. mssql_python/libs/linux/debian_ubuntu/arm64/lib/MICROSOFT_ODBC_DRIVER_FOR_SQL_SERVER_LICENSE.txt +76 -0
  23. mssql_python/libs/linux/debian_ubuntu/arm64/lib/libmsodbcsql-18.5.so.1.1 +0 -0
  24. mssql_python/libs/linux/debian_ubuntu/arm64/lib/libodbcinst.so.2 +0 -0
  25. mssql_python/libs/linux/debian_ubuntu/arm64/share/resources/en_US/msodbcsqlr18.rll +0 -0
  26. mssql_python/libs/linux/debian_ubuntu/x86_64/lib/MICROSOFT_ODBC_DRIVER_FOR_SQL_SERVER_LICENSE.txt +76 -0
  27. mssql_python/libs/linux/debian_ubuntu/x86_64/lib/libmsodbcsql-18.5.so.1.1 +0 -0
  28. mssql_python/libs/linux/debian_ubuntu/x86_64/lib/libodbcinst.so.2 +0 -0
  29. mssql_python/libs/linux/debian_ubuntu/x86_64/share/resources/en_US/msodbcsqlr18.rll +0 -0
  30. mssql_python/libs/linux/rhel/arm64/lib/MICROSOFT_ODBC_DRIVER_FOR_SQL_SERVER_LICENSE.txt +76 -0
  31. mssql_python/libs/linux/rhel/arm64/lib/libmsodbcsql-18.5.so.1.1 +0 -0
  32. mssql_python/libs/linux/rhel/arm64/lib/libodbcinst.so.2 +0 -0
  33. mssql_python/libs/linux/rhel/arm64/share/resources/en_US/msodbcsqlr18.rll +0 -0
  34. mssql_python/libs/linux/rhel/x86_64/lib/MICROSOFT_ODBC_DRIVER_FOR_SQL_SERVER_LICENSE.txt +76 -0
  35. mssql_python/libs/linux/rhel/x86_64/lib/libmsodbcsql-18.5.so.1.1 +0 -0
  36. mssql_python/libs/linux/rhel/x86_64/lib/libodbcinst.so.2 +0 -0
  37. mssql_python/libs/linux/rhel/x86_64/share/resources/en_US/msodbcsqlr18.rll +0 -0
  38. mssql_python/libs/linux/suse/x86_64/lib/libmsodbcsql-18.5.so.1.1 +0 -0
  39. mssql_python/libs/linux/suse/x86_64/lib/libodbcinst.so.2 +0 -0
  40. mssql_python/libs/linux/suse/x86_64/share/resources/en_US/msodbcsqlr18.rll +0 -0
  41. mssql_python/libs/macos/arm64/lib/MICROSOFT_ODBC_DRIVER_FOR_SQL_SERVER_LICENSE.txt +76 -0
  42. mssql_python/libs/macos/arm64/lib/libltdl.7.dylib +0 -0
  43. mssql_python/libs/macos/arm64/lib/libmsodbcsql.18.dylib +0 -0
  44. mssql_python/libs/macos/arm64/lib/libodbc.2.dylib +0 -0
  45. mssql_python/libs/macos/arm64/lib/libodbcinst.2.dylib +0 -0
  46. mssql_python/libs/macos/arm64/share/doc/msodbcsql18/LICENSE.txt +101 -0
  47. mssql_python/libs/macos/arm64/share/doc/msodbcsql18/RELEASE_NOTES +465 -0
  48. mssql_python/libs/macos/arm64/share/msodbcsql18/resources/en_US/msodbcsqlr18.rll +0 -0
  49. mssql_python/libs/macos/x86_64/lib/MICROSOFT_ODBC_DRIVER_FOR_SQL_SERVER_LICENSE.txt +76 -0
  50. mssql_python/libs/macos/x86_64/lib/libltdl.7.dylib +0 -0
  51. mssql_python/libs/macos/x86_64/lib/libmsodbcsql.18.dylib +0 -0
  52. mssql_python/libs/macos/x86_64/lib/libodbc.2.dylib +0 -0
  53. mssql_python/libs/macos/x86_64/lib/libodbcinst.2.dylib +0 -0
  54. mssql_python/libs/macos/x86_64/share/doc/msodbcsql18/LICENSE.txt +101 -0
  55. mssql_python/libs/macos/x86_64/share/doc/msodbcsql18/RELEASE_NOTES +465 -0
  56. mssql_python/libs/macos/x86_64/share/msodbcsql18/resources/en_US/msodbcsqlr18.rll +0 -0
  57. mssql_python/libs/windows/x64/1033/msodbcsqlr18.rll +0 -0
  58. mssql_python/libs/windows/x64/MICROSOFT_ODBC_DRIVER_FOR_SQL_SERVER_LICENSE.txt +76 -0
  59. mssql_python/libs/windows/x64/MICROSOFT_VISUAL_STUDIO_LICENSE.txt +54 -0
  60. mssql_python/libs/windows/x64/msodbcdiag18.dll +0 -0
  61. mssql_python/libs/windows/x64/msodbcsql18.dll +0 -0
  62. mssql_python/libs/windows/x64/mssql-auth.dll +0 -0
  63. mssql_python/logging.py +610 -0
  64. mssql_python/mssql_python.pyi +375 -0
  65. mssql_python/msvcp140.dll +0 -0
  66. mssql_python/pooling.py +125 -0
  67. mssql_python/row.py +194 -0
  68. mssql_python/type.py +143 -0
  69. mssql_python-1.0.0.dist-info/METADATA +76 -0
  70. mssql_python-1.0.0.dist-info/RECORD +73 -0
  71. mssql_python-1.0.0.dist-info/WHEEL +5 -0
  72. mssql_python-1.0.0.dist-info/licenses/LICENSE +47 -0
  73. mssql_python-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,53 @@
1
+ """
2
+ Copyright (c) Microsoft Corporation.
3
+ Licensed under the MIT license.
4
+ This module provides a way to create a new connection object to interact with the database.
5
+ """
6
+
7
+ from typing import Any, Dict, Optional, Union
8
+
9
+ from mssql_python.connection import Connection
10
+
11
+
12
+ def connect(
13
+ connection_str: str = "",
14
+ autocommit: bool = False,
15
+ attrs_before: Optional[Dict[int, Union[int, str, bytes]]] = None,
16
+ timeout: int = 0,
17
+ **kwargs: Any
18
+ ) -> Connection:
19
+ """
20
+ Constructor for creating a connection to the database.
21
+
22
+ Args:
23
+ connection_str (str): The connection string to connect to.
24
+ autocommit (bool): If True, causes a commit to be performed after each SQL statement.
25
+ TODO: Add the following parameters to the function signature:
26
+ timeout (int): The timeout for the connection attempt, in seconds.
27
+ readonly (bool): If True, the connection is set to read-only.
28
+ attrs_before (dict): A dictionary of connection attributes to set before connecting.
29
+ Keyword Args:
30
+ **kwargs: Additional key/value pairs for the connection string.
31
+ Below attributes are not implemented in the internal driver:
32
+ - encoding (str): The encoding for the connection string.
33
+ - ansi (bool): If True, indicates the driver does not support Unicode.
34
+
35
+ Returns:
36
+ Connection: A new connection object to interact with the database.
37
+
38
+ Raises:
39
+ DatabaseError: If there is an error while trying to connect to the database.
40
+ InterfaceError: If there is an error related to the database interface.
41
+
42
+ This function provides a way to create a new connection object, which can then
43
+ be used to perform database operations such as executing queries, committing
44
+ transactions, and closing the connection.
45
+ """
46
+ conn = Connection(
47
+ connection_str,
48
+ autocommit=autocommit,
49
+ attrs_before=attrs_before,
50
+ timeout=timeout,
51
+ **kwargs
52
+ )
53
+ return conn
@@ -0,0 +1,137 @@
1
+ """
2
+ Dynamic loading of platform-specific DDBC bindings for mssql-python.
3
+
4
+ This module handles the runtime loading of the appropriate compiled extension
5
+ module based on the current platform, architecture, and Python version.
6
+ """
7
+
8
+ import os
9
+ import importlib.util
10
+ import sys
11
+ import platform
12
+
13
+ def normalize_architecture(platform_name_param, architecture_param):
14
+ """
15
+ Normalize architecture names for the given platform.
16
+
17
+ Args:
18
+ platform_name_param (str): Platform name ('windows', 'darwin', 'linux')
19
+ architecture_param (str): Architecture string to normalize
20
+
21
+ Returns:
22
+ str: Normalized architecture name
23
+
24
+ Raises:
25
+ ImportError: If architecture is not supported for the given platform
26
+ OSError: If platform is not supported
27
+ """
28
+ arch_lower = architecture_param.lower()
29
+
30
+ if platform_name_param == "windows":
31
+ arch_map = {
32
+ "win64": "x64",
33
+ "amd64": "x64",
34
+ "x64": "x64",
35
+ "win32": "x86",
36
+ "x86": "x86",
37
+ "arm64": "arm64",
38
+ }
39
+ if arch_lower in arch_map:
40
+ return arch_map[arch_lower]
41
+ supported = list(set(arch_map.keys()))
42
+ raise ImportError(
43
+ f"Unsupported architecture '{architecture_param}' for platform "
44
+ f"'{platform_name_param}'; expected one of {supported}"
45
+ )
46
+
47
+ if platform_name_param == "darwin":
48
+ # For macOS, return runtime architecture
49
+ return platform.machine().lower()
50
+
51
+ if platform_name_param == "linux":
52
+ arch_map = {
53
+ "x64": "x86_64",
54
+ "amd64": "x86_64",
55
+ "x86_64": "x86_64",
56
+ "arm64": "arm64",
57
+ "aarch64": "arm64",
58
+ }
59
+ if arch_lower in arch_map:
60
+ return arch_map[arch_lower]
61
+ supported = list(set(arch_map.keys()))
62
+ raise ImportError(
63
+ f"Unsupported architecture '{architecture_param}' for platform "
64
+ f"'{platform_name_param}'; expected one of {supported}"
65
+ )
66
+
67
+ supported_platforms_list = ["windows", "darwin", "linux"]
68
+ raise OSError(
69
+ f"Unsupported platform '{platform_name_param}'; expected one of "
70
+ f"{supported_platforms_list}"
71
+ )
72
+
73
+
74
+ # Get current Python version and architecture
75
+ python_version = f"cp{sys.version_info.major}{sys.version_info.minor}"
76
+
77
+ platform_name = platform.system().lower()
78
+ raw_architecture = platform.machine().lower()
79
+
80
+ # Special handling for macOS universal2 binaries
81
+ if platform_name == "darwin":
82
+ architecture = "universal2"
83
+ else:
84
+ architecture = normalize_architecture(platform_name, raw_architecture)
85
+
86
+ # Handle Windows-specific naming for binary files
87
+ if platform_name == "windows" and architecture == "x64":
88
+ architecture = "amd64"
89
+
90
+ # Validate supported platforms
91
+ if platform_name not in ["windows", "darwin", "linux"]:
92
+ supported_platforms = ["windows", "darwin", "linux"]
93
+ raise ImportError(
94
+ f"Unsupported platform '{platform_name}' for mssql-python; expected one "
95
+ f"of {supported_platforms}"
96
+ )
97
+
98
+ # Determine extension based on platform
99
+ if platform_name == "windows":
100
+ extension = ".pyd"
101
+ else: # macOS or Linux
102
+ extension = ".so"
103
+
104
+ # Find the specifically matching module file
105
+ module_dir = os.path.dirname(__file__)
106
+ expected_module = f"ddbc_bindings.{python_version}-{architecture}{extension}"
107
+ module_path = os.path.join(module_dir, expected_module)
108
+
109
+ if not os.path.exists(module_path):
110
+ # Fallback to searching for any matching module if the specific one isn't found
111
+ module_files = [
112
+ f
113
+ for f in os.listdir(module_dir)
114
+ if f.startswith("ddbc_bindings.") and f.endswith(extension)
115
+ ]
116
+ if not module_files:
117
+ raise ImportError(
118
+ f"No ddbc_bindings module found for {python_version}-{architecture} "
119
+ f"with extension {extension}"
120
+ )
121
+ module_path = os.path.join(module_dir, module_files[0])
122
+ print(
123
+ f"Warning: Using fallback module file {module_files[0]} instead of "
124
+ f"{expected_module}"
125
+ )
126
+
127
+ # Use the original module name 'ddbc_bindings' that the C extension was compiled with
128
+ module_name = "ddbc_bindings"
129
+ spec = importlib.util.spec_from_file_location(module_name, module_path)
130
+ module = importlib.util.module_from_spec(spec)
131
+ sys.modules[module_name] = module
132
+ spec.loader.exec_module(module)
133
+
134
+ # Copy all attributes from the loaded module to this module
135
+ for attr in dir(module):
136
+ if not attr.startswith("__"):
137
+ globals()[attr] = getattr(module, attr)