Skip to content

Commit a1b0603

Browse files
committed
fix
1 parent 5830dc2 commit a1b0603

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

mssql_python/pybind/ddbc_bindings.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,7 +2822,7 @@ SQLRETURN SQLGetData_wrap(SqlHandlePtr StatementHandle, SQLUSMALLINT colCount, p
28222822
sizeof(timestampValue), NULL);
28232823
if (SQL_SUCCEEDED(ret)) {
28242824
row.append(
2825-
PythonObjectCache::datetime_class(
2825+
PythonObjectCache::get_datetime_class()(
28262826
timestampValue.year,
28272827
timestampValue.month,
28282828
timestampValue.day,
@@ -3649,7 +3649,7 @@ SQLRETURN FetchAll_wrap(SqlHandlePtr StatementHandle, py::list& rows) {
36493649
}
36503650

36513651
// Define a memory limit (1 GB)
3652-
const size_t memoryLimit = 1ULL * 1024 * 1024;
3652+
const size_t memoryLimit = 1ULL * 1024 * 1024 * 1024;
36533653
size_t totalRowSize = calculateRowSize(columnNames, numCols);
36543654

36553655
// Calculate fetch size based on the total row size and memory limit
@@ -3677,6 +3677,9 @@ SQLRETURN FetchAll_wrap(SqlHandlePtr StatementHandle, py::list& rows) {
36773677
// If the row size is larger than the memory limit, fetch one row at a time
36783678
fetchSize = 1;
36793679
} else if (numRowsInMemLimit > 0 && numRowsInMemLimit <= 100) {
3680+
// If between 1-100 rows fit in memoryLimit, fetch 10 rows at a time
3681+
fetchSize = 10;
3682+
} else if (numRowsInMemLimit > 100 && numRowsInMemLimit <= 1000) {
36803683
// If between 100-1000 rows fit in memoryLimit, fetch 100 rows at a time
36813684
fetchSize = 100;
36823685
} else {

tests/test_005_connection_cursor_lifecycle.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,18 +610,19 @@ def test_concurrent_cursor_operations_no_segfault(conn_str):
610610
import threading
611611
from mssql_python import connect
612612
613-
conn = connect("{escaped_conn_str}")
614613
results = []
615614
exceptions = []
616615
617616
def worker(thread_id):
618617
try:
618+
conn = connect("{escaped_conn_str}")
619619
for i in range(15):
620620
cursor = conn.cursor()
621621
cursor.execute(f"SELECT {{thread_id * 100 + i}} as value")
622622
result = cursor.fetchone()
623623
results.append(result[0])
624624
# Don't explicitly close cursor - test concurrent destructors
625+
conn.close()
625626
except Exception as e:
626627
exceptions.append(f"Thread {{thread_id}}: {{e}}")
627628

0 commit comments

Comments
 (0)