main commit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-16 16:30:25 +09:00
parent 91c7e04474
commit 537e7b363f
1146 changed files with 45926 additions and 77196 deletions

View File

@@ -1,5 +1,5 @@
# connectors/pyodbc.py
# Copyright (C) 2005-2025 the SQLAlchemy authors and contributors
# Copyright (C) 2005-2023 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
@@ -8,6 +8,7 @@
from __future__ import annotations
import re
from types import ModuleType
import typing
from typing import Any
from typing import Dict
@@ -28,7 +29,6 @@ from ..engine import URL
from ..sql.type_api import TypeEngine
if typing.TYPE_CHECKING:
from ..engine.interfaces import DBAPIModule
from ..engine.interfaces import IsolationLevel
@@ -48,13 +48,15 @@ class PyODBCConnector(Connector):
# hold the desired driver name
pyodbc_driver_name: Optional[str] = None
dbapi: ModuleType
def __init__(self, use_setinputsizes: bool = False, **kw: Any):
super().__init__(**kw)
if use_setinputsizes:
self.bind_typing = interfaces.BindTyping.SETINPUTSIZES
@classmethod
def import_dbapi(cls) -> DBAPIModule:
def import_dbapi(cls) -> ModuleType:
return __import__("pyodbc")
def create_connect_args(self, url: URL) -> ConnectArgsType:
@@ -148,7 +150,7 @@ class PyODBCConnector(Connector):
],
cursor: Optional[interfaces.DBAPICursor],
) -> bool:
if isinstance(e, self.loaded_dbapi.ProgrammingError):
if isinstance(e, self.dbapi.ProgrammingError):
return "The cursor's connection has been closed." in str(
e
) or "Attempt to use a closed connection." in str(e)
@@ -215,19 +217,19 @@ class PyODBCConnector(Connector):
cursor.setinputsizes(
[
(
(dbtype, None, None)
if not isinstance(dbtype, tuple)
else dbtype
)
(dbtype, None, None)
if not isinstance(dbtype, tuple)
else dbtype
for key, dbtype, sqltype in list_of_tuples
]
)
def get_isolation_level_values(
self, dbapi_conn: interfaces.DBAPIConnection
self, dbapi_connection: interfaces.DBAPIConnection
) -> List[IsolationLevel]:
return [*super().get_isolation_level_values(dbapi_conn), "AUTOCOMMIT"]
return super().get_isolation_level_values(dbapi_connection) + [
"AUTOCOMMIT"
]
def set_isolation_level(
self,
@@ -243,8 +245,3 @@ class PyODBCConnector(Connector):
else:
dbapi_connection.autocommit = False
super().set_isolation_level(dbapi_connection, level)
def detect_autocommit_setting(
self, dbapi_conn: interfaces.DBAPIConnection
) -> bool:
return bool(dbapi_conn.autocommit)