mssql-python 1.0.0a0__cp313-cp313-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.
Potentially problematic release.
This version of mssql-python might be problematic. Click here for more details.
- mssql_python/__init__.py +31 -0
- mssql_python/connection.py +302 -0
- mssql_python/constants.py +108 -0
- mssql_python/cursor.py +688 -0
- mssql_python/db_connection.py +37 -0
- mssql_python/ddbc_bindings.pyd +0 -0
- mssql_python/exceptions.py +254 -0
- mssql_python/helpers.py +99 -0
- mssql_python/libs/win/1033/msodbcsqlr18.rll +0 -0
- mssql_python/libs/win/msodbcdiag18.dll +0 -0
- mssql_python/libs/win/msodbcsql18.dll +0 -0
- mssql_python/logging_config.py +56 -0
- mssql_python/mssql_python.pyi +177 -0
- mssql_python/msvcp140.dll +0 -0
- mssql_python/testing_ddbc_bindings.py +321 -0
- mssql_python/type.py +81 -0
- mssql_python-1.0.0a0.dist-info/METADATA +24 -0
- mssql_python-1.0.0a0.dist-info/RECORD +20 -0
- mssql_python-1.0.0a0.dist-info/WHEEL +5 -0
- mssql_python-1.0.0a0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
import datetime
|
|
3
|
+
import ddbc_bindings
|
|
4
|
+
import decimal
|
|
5
|
+
import os
|
|
6
|
+
from logging_config import setup_logging
|
|
7
|
+
|
|
8
|
+
setup_logging()
|
|
9
|
+
|
|
10
|
+
# Constants
|
|
11
|
+
SQL_HANDLE_ENV = 1
|
|
12
|
+
SQL_HANDLE_DBC = 2
|
|
13
|
+
SQL_HANDLE_STMT = 3
|
|
14
|
+
SQL_ATTR_DDBC_VERSION = 200
|
|
15
|
+
SQL_OV_DDBC3_80 = 380
|
|
16
|
+
SQL_DRIVER_NOPROMPT = 0
|
|
17
|
+
SQL_NTS = -3 # SQL_NULL_TERMINATED for indicating string length in SQLDriverConnect
|
|
18
|
+
SQL_NO_DATA = 100 # This is the value to indicate that there is no more data
|
|
19
|
+
|
|
20
|
+
def alloc_handle(handle_type, input_handle):
|
|
21
|
+
handle = ctypes.c_void_p()
|
|
22
|
+
result = ddbc_bindings.DDBCSQLAllocHandle(handle_type, input_handle, ctypes.cast(ctypes.pointer(handle), ctypes.c_void_p).value)
|
|
23
|
+
if result < 0:
|
|
24
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(handle_type, handle.value, result))
|
|
25
|
+
raise RuntimeError(f"Failed to allocate handle. Error code: {result}")
|
|
26
|
+
return handle
|
|
27
|
+
|
|
28
|
+
def free_handle(handle_type, handle):
|
|
29
|
+
result = ddbc_bindings.DDBCSQLFreeHandle(handle_type, handle.value)
|
|
30
|
+
if result < 0:
|
|
31
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(handle_type, handle.value, result))
|
|
32
|
+
raise RuntimeError(f"Failed to free handle. Error code: {result}")
|
|
33
|
+
|
|
34
|
+
def ddbc_sql_execute(stmt_handle, query, params, param_info_list, is_stmt_prepared, use_prepare=True):
|
|
35
|
+
result = ddbc_bindings.DDBCSQLExecute(stmt_handle.value, query, params, param_info_list, is_stmt_prepared, use_prepare)
|
|
36
|
+
if result < 0:
|
|
37
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(SQL_HANDLE_STMT, stmt_handle.value, result))
|
|
38
|
+
raise RuntimeError(f"Failed to execute query. Error code: {result}")
|
|
39
|
+
return result
|
|
40
|
+
|
|
41
|
+
def fetch_data_onebyone(stmt_handle):
|
|
42
|
+
rows = []
|
|
43
|
+
ret = 1
|
|
44
|
+
while ret != SQL_NO_DATA:
|
|
45
|
+
row = []
|
|
46
|
+
ret = ddbc_bindings.DDBCSQLFetchOne(stmt_handle.value, row)
|
|
47
|
+
if ret < 0:
|
|
48
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(SQL_HANDLE_STMT, stmt_handle.value, ret))
|
|
49
|
+
raise RuntimeError(f"Failed to fetch data. Error code: {ret}")
|
|
50
|
+
print(row)
|
|
51
|
+
rows.append(row)
|
|
52
|
+
return rows
|
|
53
|
+
|
|
54
|
+
def fetch_data_many(stmt_handle):
|
|
55
|
+
rows = []
|
|
56
|
+
ret = 1
|
|
57
|
+
while ret != SQL_NO_DATA:
|
|
58
|
+
ret = ddbc_bindings.DDBCSQLFetchMany(stmt_handle.value, rows, 10)
|
|
59
|
+
if ret < 0:
|
|
60
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(SQL_HANDLE_STMT, stmt_handle.value, ret))
|
|
61
|
+
raise RuntimeError(f"Failed to fetch data. Error code: {ret}")
|
|
62
|
+
return rows
|
|
63
|
+
|
|
64
|
+
def fetch_data_all(stmt_handle):
|
|
65
|
+
rows = []
|
|
66
|
+
ret = 1
|
|
67
|
+
ret = ddbc_bindings.DDBCSQLFetchAll(stmt_handle.value, rows)
|
|
68
|
+
if ret != SQL_NO_DATA:
|
|
69
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(SQL_HANDLE_STMT, stmt_handle.value, ret))
|
|
70
|
+
raise RuntimeError(f"Failed to fetch data. Error code: {ret}")
|
|
71
|
+
return rows
|
|
72
|
+
|
|
73
|
+
def fetch_data(stmt_handle):
|
|
74
|
+
rows = []
|
|
75
|
+
column_count = ddbc_bindings.DDBCSQLNumResultCols(stmt_handle.value)
|
|
76
|
+
print("Number of columns = " + str(column_count))
|
|
77
|
+
while True:
|
|
78
|
+
result = ddbc_bindings.DDBCSQLFetch(stmt_handle.value)
|
|
79
|
+
if result == SQL_NO_DATA:
|
|
80
|
+
break
|
|
81
|
+
elif result < 0:
|
|
82
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(SQL_HANDLE_STMT, stmt_handle.value, result))
|
|
83
|
+
raise RuntimeError(f"Failed to fetch data. Error code: {result}")
|
|
84
|
+
if column_count > 0:
|
|
85
|
+
row = []
|
|
86
|
+
result = ddbc_bindings.DDBCSQLGetData(stmt_handle.value, column_count, row)
|
|
87
|
+
if result < 0:
|
|
88
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(SQL_HANDLE_STMT, stmt_handle.value, result))
|
|
89
|
+
raise RuntimeError(f"Failed to get data. Error code: {result}")
|
|
90
|
+
rows.append(row)
|
|
91
|
+
return rows
|
|
92
|
+
|
|
93
|
+
def describe_columns(stmt_handle):
|
|
94
|
+
column_names = []
|
|
95
|
+
result = ddbc_bindings.DDBCSQLDescribeCol(stmt_handle.value, column_names)
|
|
96
|
+
if result < 0:
|
|
97
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(SQL_HANDLE_STMT, stmt_handle.value, result))
|
|
98
|
+
raise RuntimeError(f"Failed to describe columns. Error code: {result}")
|
|
99
|
+
return column_names
|
|
100
|
+
|
|
101
|
+
def connect_to_db(dbc_handle, connection_string):
|
|
102
|
+
result = ddbc_bindings.DDBCSQLDriverConnect(dbc_handle.value, 0, connection_string)
|
|
103
|
+
if result < 0:
|
|
104
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(SQL_HANDLE_DBC, dbc_handle.value, result))
|
|
105
|
+
raise RuntimeError(f"SQLDriverConnect failed. Error code: {result}")
|
|
106
|
+
|
|
107
|
+
def add_string_param(params, paramInfos, data_string):
|
|
108
|
+
params.append(data_string)
|
|
109
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
110
|
+
paramInfo.paramCType = 1 # SQL_C_CHAR
|
|
111
|
+
paramInfo.paramSQLType = 12 # SQL_VARCHAR
|
|
112
|
+
paramInfo.columnSize = len(data_string)
|
|
113
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
114
|
+
paramInfos.append(paramInfo)
|
|
115
|
+
|
|
116
|
+
def add_wstring_param(params, paramInfos, wide_string):
|
|
117
|
+
params.append(wide_string)
|
|
118
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
119
|
+
paramInfo.paramCType = -8 # SQL_C_WCHAR
|
|
120
|
+
paramInfo.paramSQLType = -9 # SQL_WVARCHAR
|
|
121
|
+
paramInfo.columnSize = len(wide_string)
|
|
122
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
123
|
+
paramInfos.append(paramInfo)
|
|
124
|
+
|
|
125
|
+
def add_date_param(params, paramInfos):
|
|
126
|
+
date_obj = datetime.date(2025, 1, 28) # 28th Jan 2025
|
|
127
|
+
params.append(date_obj)
|
|
128
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
129
|
+
paramInfo.paramCType = 91 # SQL_C_TYPE_DATE
|
|
130
|
+
paramInfo.paramSQLType = 91 # SQL_TYPE_DATE
|
|
131
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
132
|
+
paramInfos.append(paramInfo)
|
|
133
|
+
|
|
134
|
+
def add_time_param(params, paramInfos):
|
|
135
|
+
time_obj = datetime.time(5, 15, 30) # 5:15 AM + 30 secs
|
|
136
|
+
params.append(time_obj)
|
|
137
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
138
|
+
paramInfo.paramCType = 92 # SQL_C_TYPE_TIME
|
|
139
|
+
paramInfo.paramSQLType = 92 # SQL_TYPE_TIME
|
|
140
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
141
|
+
paramInfos.append(paramInfo)
|
|
142
|
+
|
|
143
|
+
def add_datetime_param(params, paramInfos, addNone):
|
|
144
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
145
|
+
if addNone:
|
|
146
|
+
params.append(None)
|
|
147
|
+
paramInfo.paramCType = 99 # SQL_C_DEFAULT
|
|
148
|
+
else:
|
|
149
|
+
datetime_obj = datetime.datetime(2025, 1, 28, 5, 15, 30)
|
|
150
|
+
params.append(datetime_obj)
|
|
151
|
+
paramInfo.paramCType = 93 # SQL_C_TYPE_TIMESTAMP
|
|
152
|
+
paramInfo.paramSQLType = 93 # SQL_TYPE_TIMESTAMP
|
|
153
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
154
|
+
paramInfos.append(paramInfo)
|
|
155
|
+
|
|
156
|
+
def add_bool_param(params, paramInfos, bool_val):
|
|
157
|
+
params.append(bool_val)
|
|
158
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
159
|
+
paramInfo.paramCType = -7 # SQL_C_BIT
|
|
160
|
+
paramInfo.paramSQLType = -7 # SQL_BIT
|
|
161
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
162
|
+
paramInfos.append(paramInfo)
|
|
163
|
+
|
|
164
|
+
def add_tinyint_param(params, paramInfos, val):
|
|
165
|
+
params.append(val)
|
|
166
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
167
|
+
paramInfo.paramCType = -6 # SQL_C_TINYINT
|
|
168
|
+
paramInfo.paramSQLType = -6 # SQL_TINYINT
|
|
169
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
170
|
+
paramInfos.append(paramInfo)
|
|
171
|
+
|
|
172
|
+
def add_bigint_param(params, paramInfos, val):
|
|
173
|
+
params.append(val)
|
|
174
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
175
|
+
paramInfo.paramCType = -25 # SQL_C_SBIGINT
|
|
176
|
+
paramInfo.paramSQLType = -5 # SQL_BIGINT
|
|
177
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
178
|
+
paramInfos.append(paramInfo)
|
|
179
|
+
|
|
180
|
+
def add_float_param(params, paramInfos, val):
|
|
181
|
+
params.append(val)
|
|
182
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
183
|
+
paramInfo.paramCType = 7 # SQL_C_FLOAT
|
|
184
|
+
paramInfo.paramSQLType = 7 # SQL_REAL
|
|
185
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
186
|
+
paramInfo.columnSize = 15 # Precision
|
|
187
|
+
paramInfos.append(paramInfo)
|
|
188
|
+
|
|
189
|
+
def add_double_param(params, paramInfos, val):
|
|
190
|
+
params.append(val)
|
|
191
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
192
|
+
paramInfo.paramCType = 8 # SQL_C_DOUBLE
|
|
193
|
+
paramInfo.paramSQLType = 8 # SQL_DOUBLE
|
|
194
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
195
|
+
paramInfo.columnSize = 15 # Precision
|
|
196
|
+
paramInfos.append(paramInfo)
|
|
197
|
+
|
|
198
|
+
def add_numeric_param(params, paramInfos, param):
|
|
199
|
+
numericdata = ddbc_bindings.NumericData()
|
|
200
|
+
numericdata.precision = len(param.as_tuple().digits)
|
|
201
|
+
numericdata.scale = param.as_tuple().exponent * -1
|
|
202
|
+
numericdata.sign = param.as_tuple().sign
|
|
203
|
+
numericdata.val = str(param)
|
|
204
|
+
print(type(numericdata.precision),type(numericdata.scale),type(numericdata.sign), type(numericdata.val), type(numericdata))
|
|
205
|
+
params.append(numericdata)
|
|
206
|
+
|
|
207
|
+
paramInfo = ddbc_bindings.ParamInfo()
|
|
208
|
+
paramInfo.paramCType = 2 # SQL_C_NUMERIC
|
|
209
|
+
paramInfo.paramSQLType = 2 # SQL_NUMERIC
|
|
210
|
+
paramInfo.inputOutputType = 1 # SQL_PARAM_INPUT
|
|
211
|
+
paramInfo.columnSize = 10 # Precision
|
|
212
|
+
paramInfos.append(paramInfo)
|
|
213
|
+
|
|
214
|
+
if __name__ == "__main__":
|
|
215
|
+
# Allocate environment handle
|
|
216
|
+
env_handle = alloc_handle(SQL_HANDLE_ENV, 0)
|
|
217
|
+
|
|
218
|
+
# Set the DDBC version environment attribute
|
|
219
|
+
result = ddbc_bindings.DDBCSQLSetEnvAttr(env_handle.value, SQL_ATTR_DDBC_VERSION, SQL_OV_DDBC3_80, 0)
|
|
220
|
+
if result < 0:
|
|
221
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(SQL_HANDLE_ENV, env_handle.value, result))
|
|
222
|
+
raise RuntimeError(f"Failed to set DDBC version attribute. Error code: {result}")
|
|
223
|
+
|
|
224
|
+
# Allocate connection handle
|
|
225
|
+
dbc_handle = alloc_handle(SQL_HANDLE_DBC, env_handle.value)
|
|
226
|
+
|
|
227
|
+
# Fetch the connection string from environment variables
|
|
228
|
+
connection_string = os.getenv("DB_CONNECTION_STRING")
|
|
229
|
+
if not connection_string:
|
|
230
|
+
raise EnvironmentError("Environment variable 'DB_CONNECTION_STRING' is not set or is empty.")
|
|
231
|
+
|
|
232
|
+
print("Connecting!")
|
|
233
|
+
connect_to_db(dbc_handle, connection_string)
|
|
234
|
+
print("Connection successful!")
|
|
235
|
+
|
|
236
|
+
# Allocate connection statement handle
|
|
237
|
+
stmt_handle = alloc_handle(SQL_HANDLE_STMT, dbc_handle.value)
|
|
238
|
+
|
|
239
|
+
ParamInfo = ddbc_bindings.ParamInfo
|
|
240
|
+
'''
|
|
241
|
+
Table schema:
|
|
242
|
+
CREATE TABLE customers (
|
|
243
|
+
id INT IDENTITY(1,1) PRIMARY KEY,
|
|
244
|
+
name NVARCHAR(100),
|
|
245
|
+
email NVARCHAR(100)
|
|
246
|
+
);
|
|
247
|
+
'''
|
|
248
|
+
# Test DDBCSQLExecute for INSERT query
|
|
249
|
+
print("Test DDBCSQLExecute insert")
|
|
250
|
+
'''
|
|
251
|
+
insert_sql_query = """
|
|
252
|
+
ALTER TABLE [Employees].[dbo].[EmployeeFullNames]
|
|
253
|
+
ADD date_ DATE,
|
|
254
|
+
time_ TIME,
|
|
255
|
+
datetime_ TIMESTAMP,
|
|
256
|
+
wchar_ NVARCHAR(10),
|
|
257
|
+
bool_ BIT,
|
|
258
|
+
tinyint_ TINYINT,
|
|
259
|
+
bigint_ BIGINT,
|
|
260
|
+
float_ FLOAT(10),
|
|
261
|
+
double_ DOUBLE PRECISION;
|
|
262
|
+
|
|
263
|
+
"""
|
|
264
|
+
'''
|
|
265
|
+
insert_sql_query = "INSERT INTO [Employees].[dbo].[EmployeeFullNames] (FirstName, LastName, date_, time_, wchar_, bool_, tinyint_, bigint_, float_, double_) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"
|
|
266
|
+
params = []
|
|
267
|
+
param_info_list = []
|
|
268
|
+
add_string_param(params, param_info_list, 'test')
|
|
269
|
+
add_string_param(params, param_info_list, 'inner file')
|
|
270
|
+
add_date_param(params, param_info_list)
|
|
271
|
+
add_time_param(params, param_info_list)
|
|
272
|
+
# add_datetime_param(params, param_info_list, addNone=True) - Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column. Traceback (most recent call last):
|
|
273
|
+
add_wstring_param(params, param_info_list, u"Wide str3")
|
|
274
|
+
add_bool_param(params, param_info_list, True)
|
|
275
|
+
add_tinyint_param(params, param_info_list, 127)
|
|
276
|
+
add_bigint_param(params, param_info_list, 123456789)
|
|
277
|
+
add_float_param(params, param_info_list, 12.34)
|
|
278
|
+
add_double_param(params, param_info_list, 12.34)
|
|
279
|
+
#add_numeric_param(params, param_info_list, decimal.Decimal('12'))
|
|
280
|
+
is_stmt_prepared = [False]
|
|
281
|
+
result = ddbc_sql_execute(stmt_handle, insert_sql_query, params, param_info_list, is_stmt_prepared, True)
|
|
282
|
+
print("DDBCSQLExecute result:", result)
|
|
283
|
+
|
|
284
|
+
# Test DDBCSQLExecute for SELECT query
|
|
285
|
+
print("Test DDBCSQLExecute select")
|
|
286
|
+
# select_sql_query = "SELECT * FROM customers;"
|
|
287
|
+
is_stmt_prepared = [False]
|
|
288
|
+
select_sql_query = "SELECT bool_, float_, wchar_, date_, time_, datetime_, wchar_, FirstName, LastName FROM [Employees].[dbo].[EmployeeFullNames];"
|
|
289
|
+
params = []
|
|
290
|
+
param_info_list = []
|
|
291
|
+
result = ddbc_sql_execute(stmt_handle, select_sql_query, params, param_info_list, is_stmt_prepared, False)
|
|
292
|
+
print("DDBCSQLExecute result:", result)
|
|
293
|
+
|
|
294
|
+
print("Fetching Data for DDBCSQLExecute!")
|
|
295
|
+
column_names = describe_columns(stmt_handle)
|
|
296
|
+
print(column_names)
|
|
297
|
+
ret = 1
|
|
298
|
+
while ret != SQL_NO_DATA:
|
|
299
|
+
if column_names:
|
|
300
|
+
rows = fetch_data_all(stmt_handle)
|
|
301
|
+
for row in rows:
|
|
302
|
+
print(row)
|
|
303
|
+
else:
|
|
304
|
+
print("No columns to fetch data from.")
|
|
305
|
+
ret = ddbc_bindings.DDBCSQLMoreResults(stmt_handle.value)
|
|
306
|
+
|
|
307
|
+
# Free the statement handle
|
|
308
|
+
free_handle(SQL_HANDLE_STMT, stmt_handle)
|
|
309
|
+
# Disconnect from the data source
|
|
310
|
+
result = ddbc_bindings.DDBCSQLDisconnect(dbc_handle.value)
|
|
311
|
+
if result < 0:
|
|
312
|
+
print("Error:", ddbc_bindings.DDBCSQLCheckError(SQL_HANDLE_DBC, dbc_handle.value, result))
|
|
313
|
+
raise RuntimeError(f"Failed to disconnect from the data source. Error code: {result}")
|
|
314
|
+
|
|
315
|
+
# Free the connection handle
|
|
316
|
+
free_handle(SQL_HANDLE_DBC, dbc_handle)
|
|
317
|
+
|
|
318
|
+
# Free the environment handle
|
|
319
|
+
free_handle(SQL_HANDLE_ENV, env_handle)
|
|
320
|
+
|
|
321
|
+
print("Done!")
|
mssql_python/type.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
# Type Objects
|
|
5
|
+
class STRING:
|
|
6
|
+
"""
|
|
7
|
+
This type object is used to describe columns in a database that are string-based (e.g. CHAR).
|
|
8
|
+
"""
|
|
9
|
+
def __init__(self) -> None:
|
|
10
|
+
self.type = "STRING"
|
|
11
|
+
|
|
12
|
+
class BINARY:
|
|
13
|
+
"""
|
|
14
|
+
This type object is used to describe (long) binary columns in a database (e.g. LONG, RAW, BLOBs).
|
|
15
|
+
"""
|
|
16
|
+
def __init__(self) -> None:
|
|
17
|
+
self.type = "BINARY"
|
|
18
|
+
|
|
19
|
+
class NUMBER:
|
|
20
|
+
"""
|
|
21
|
+
This type object is used to describe numeric columns in a database.
|
|
22
|
+
"""
|
|
23
|
+
def __init__(self) -> None:
|
|
24
|
+
self.type = "NUMBER"
|
|
25
|
+
|
|
26
|
+
class DATETIME:
|
|
27
|
+
"""
|
|
28
|
+
This type object is used to describe date/time columns in a database.
|
|
29
|
+
"""
|
|
30
|
+
def __init__(self) -> None:
|
|
31
|
+
self.type = "DATETIME"
|
|
32
|
+
|
|
33
|
+
class ROWID:
|
|
34
|
+
"""
|
|
35
|
+
This type object is used to describe the “Row ID” column in a database.
|
|
36
|
+
"""
|
|
37
|
+
def __init__(self) -> None:
|
|
38
|
+
self.type = "ROWID"
|
|
39
|
+
|
|
40
|
+
# Type Constructors
|
|
41
|
+
def Date(year: int, month: int, day: int) -> datetime.date:
|
|
42
|
+
"""
|
|
43
|
+
Generates a date object.
|
|
44
|
+
"""
|
|
45
|
+
return datetime.date(year, month, day)
|
|
46
|
+
|
|
47
|
+
def Time(hour: int, minute: int, second: int) -> datetime.time:
|
|
48
|
+
"""
|
|
49
|
+
Generates a time object.
|
|
50
|
+
"""
|
|
51
|
+
return datetime.time(hour, minute, second)
|
|
52
|
+
|
|
53
|
+
def Timestamp(year: int, month: int, day: int, hour: int, minute: int, second: int) -> datetime.datetime:
|
|
54
|
+
"""
|
|
55
|
+
Generates a timestamp object.
|
|
56
|
+
"""
|
|
57
|
+
return datetime.datetime(year, month, day, hour, minute, second)
|
|
58
|
+
|
|
59
|
+
def DateFromTicks(ticks: int) -> datetime.date:
|
|
60
|
+
"""
|
|
61
|
+
Generates a date object from ticks.
|
|
62
|
+
"""
|
|
63
|
+
return datetime.date.fromtimestamp(ticks)
|
|
64
|
+
|
|
65
|
+
def TimeFromTicks(ticks: int) -> datetime.time:
|
|
66
|
+
"""
|
|
67
|
+
Generates a time object from ticks.
|
|
68
|
+
"""
|
|
69
|
+
return datetime.time(*time.gmtime(ticks)[3:6])
|
|
70
|
+
|
|
71
|
+
def TimestampFromTicks(ticks: int) -> datetime.datetime:
|
|
72
|
+
"""
|
|
73
|
+
Generates a timestamp object from ticks.
|
|
74
|
+
"""
|
|
75
|
+
return datetime.datetime.fromtimestamp(ticks, datetime.UTC)
|
|
76
|
+
|
|
77
|
+
def Binary(string: str) -> bytes:
|
|
78
|
+
"""
|
|
79
|
+
Converts a string to bytes using UTF-8 encoding.
|
|
80
|
+
"""
|
|
81
|
+
return bytes(string, 'utf-8')
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: mssql-python
|
|
3
|
+
Version: 1.0.0a0
|
|
4
|
+
Summary: A Python library for interacting with Microsoft SQL Server
|
|
5
|
+
Home-page: https://github.com/microsoft/mssql-python
|
|
6
|
+
Author: Microsoft Corporation
|
|
7
|
+
Author-email: pysqldriver@microsoft.com
|
|
8
|
+
Requires-Python: ==3.13.*
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: author-email
|
|
12
|
+
Dynamic: description
|
|
13
|
+
Dynamic: description-content-type
|
|
14
|
+
Dynamic: home-page
|
|
15
|
+
Dynamic: requires-python
|
|
16
|
+
Dynamic: summary
|
|
17
|
+
|
|
18
|
+
# mssql-python
|
|
19
|
+
|
|
20
|
+
This is a new Python driver for Microsoft SQL Server currently under development.
|
|
21
|
+
|
|
22
|
+
## Development Stage
|
|
23
|
+
|
|
24
|
+
Please note that this project is in the early stages of development. No code, logic, or binaries are present in this package at this time. This release is intended to reserve the package name on PyPI and provide a placeholder for future development. Stay tuned for updates as we continue to work on this project.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
mssql_python/__init__.py,sha256=x-IaNH16B2UETgMPIjSuUMltplxDhd7YftDwlhzk2JU,761
|
|
2
|
+
mssql_python/connection.py,sha256=uMbJg183MmD8bFxRT6zrXu5Yg_fuEqJQ9gLP18XMYIQ,12635
|
|
3
|
+
mssql_python/constants.py,sha256=tlqc90rgl8i6MOysgABwhLNkJVNNCPpiW3LXllRR2TI,2746
|
|
4
|
+
mssql_python/cursor.py,sha256=DDugQXhjLhpskPxDfQ3h4dn6CMWVAxKOA3GvzvxRBpo,28834
|
|
5
|
+
mssql_python/db_connection.py,sha256=n1jW9CsjTs7BT_47Ql7UoKuoEW0FsoKGeDoQr17En4I,1673
|
|
6
|
+
mssql_python/ddbc_bindings.pyd,sha256=tm0lAHrE6jmPWhZEqQh-jy0flrN8ribk0utfIwOAJkY,307200
|
|
7
|
+
mssql_python/exceptions.py,sha256=lKQtlrnmpD5daYf2s73mnHNn3fRG_xuFftQL9KtZS10,21512
|
|
8
|
+
mssql_python/helpers.py,sha256=tmXAk_mYXF-nzodHZ29K6_jww7LhS4RdrTErQZjgsxg,3664
|
|
9
|
+
mssql_python/logging_config.py,sha256=-GH7J2stT9bL4mWfDIqXNJ0wNlAJovNG5r-5Cukul9Y,1944
|
|
10
|
+
mssql_python/mssql_python.pyi,sha256=VZeDGARk20-dKSqwDbOmyIbYCPopAKFI2DwyzZ29kW4,4835
|
|
11
|
+
mssql_python/msvcp140.dll,sha256=kFfTmza2x9BUhl7iv5zeekkP47AexOglFGh-JPV2Jp8,575592
|
|
12
|
+
mssql_python/testing_ddbc_bindings.py,sha256=MZh6teedSH3byjYgD2VigSF9XeFqZPcVeLPC-db4-Vg,13313
|
|
13
|
+
mssql_python/type.py,sha256=BT5iA-SI3cLtQ9yPfJgf06swdPUXZWP-0VuruGFt6AY,2190
|
|
14
|
+
mssql_python/libs/win/msodbcdiag18.dll,sha256=gpVP_SjGGtK7duKBkAE-7oIAJKv3vEvKcFv8UyvzwaE,112672
|
|
15
|
+
mssql_python/libs/win/msodbcsql18.dll,sha256=ImpI1Oo4hGUUdeQgFB0RBiBPDQSAuGN-5VAMvKDI4N4,1976352
|
|
16
|
+
mssql_python/libs/win/1033/msodbcsqlr18.rll,sha256=MT5hoePh7GceYVXmqQQY5lghbXDAi0bmXfx48wlfnqw,210976
|
|
17
|
+
mssql_python-1.0.0a0.dist-info/METADATA,sha256=Rpk2EhBdejyCgXS2kspjI7KlHt3V2ETeurOko0WsLDc,928
|
|
18
|
+
mssql_python-1.0.0a0.dist-info/WHEEL,sha256=6bXTkCllrWLYPW3gCPkeRA91N4604g9hqNhQqZWsUzQ,101
|
|
19
|
+
mssql_python-1.0.0a0.dist-info/top_level.txt,sha256=6fwQBaoJlf_jkq0h4o3PZnvrg4LqyryK7_d6hLHYtaE,13
|
|
20
|
+
mssql_python-1.0.0a0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mssql_python
|