Skip to content

Commit e146e7e

Browse files
authored
FEAT: Entra ID support with mssql-auth inside package
* FEAT: Entra ID support using mssql-auth * resolved comments
1 parent a98360a commit e146e7e

File tree

6 files changed

+13
-24
lines changed

6 files changed

+13
-24
lines changed

main.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,10 @@
1212

1313
cursor = conn.cursor()
1414
cursor.execute("SELECT database_id, name from sys.databases;")
15-
row = cursor.fetchmany(1)
16-
print(row)
15+
rows = cursor.fetchall()
1716

18-
cursor.execute("DROP TABLE IF EXISTS main_single_column")
19-
20-
# cursor.execute("CREATE TABLE main_single_column (float_column FLOAT)")
21-
# cursor.executemany("INSERT INTO main_single_column (float_column) VALUES (?)", [[12.34], [1.234], [0.125], [0.0125], [0.00125], [23243243232.432432432], [0.247985732852735032750973209750]])
22-
# cursor.execute("SELECT * FROM main_single_column")
23-
# row = cursor.fetchall()
24-
# print(row)
25-
# print(len(row))
26-
27-
import time
28-
cursor.execute("CREATE TABLE main_single_column (decimal_column NUMERIC(10, 4))")
29-
# time.sleep(45)
30-
31-
cursor.execute("INSERT INTO main_single_column (decimal_column) VALUES (?)", [decimal.Decimal(123.45).quantize(decimal.Decimal('0.00'))])
32-
cursor.execute("SELECT * FROM main_single_column")
33-
row = cursor.fetchone()[0]
34-
35-
print(row)
36-
print(row.val)
37-
print(row.precision)
38-
print(row.scale)
39-
print(row.sign)
17+
for row in rows:
18+
print(f"Database ID: {row[0]}, Name: {row[1]}")
4019

4120
cursor.close()
4221
conn.close()
-3.98 KB
Binary file not shown.
24 Bytes
Binary file not shown.
4 KB
Binary file not shown.
6.21 MB
Binary file not shown.

mssql_python/pybind/ddbc_bindings.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,16 @@ void LoadDriverOrThrowException() {
246246
ThrowStdException("Failed to load driver");
247247
}
248248

249+
// Preload mssql-auth.dll from the same path if available
250+
// TODO: Only load mssql-auth.dll if using Entra ID Authentication modes (Active Directory modes)
251+
std::wstring authDllDir = std::wstring(ddbcModulePath) + L"\\libs\\win\\mssql-auth.dll";
252+
HMODULE hAuthModule = LoadLibraryW(authDllDir.c_str());
253+
if (hAuthModule) {
254+
LOG("Authentication library loaded successfully from - {}", authDllDir.c_str());
255+
} else {
256+
LOG("Note: Authentication library not found at - {}. This is OK if you're not using Entra ID Authentication.", authDllDir.c_str());
257+
}
258+
249259
// Look for msodbcsql18.dll in a path relative to DDBC module
250260
std::wstring dllDir = std::wstring(ddbcModulePath) + L"\\libs\\win\\msodbcsql18.dll";
251261
HMODULE hModule = LoadLibraryW(dllDir.c_str());

0 commit comments

Comments
 (0)