3434# ______________________________________
3535# pylint: disable=C0302, W0212, R0902, R0912,R0913, R0914, R0915, R0904
3636
37- """firebird-driver - Main driver code (connection, transaction, cursor etc.)
37+ """firebird-driver - Main driver code
38+
39+ This module implements the core components of the firebird-driver, including the DB-API 2.0
40+ compliant Connection, Cursor, and Transaction objects, as well as helper classes for managing
41+ events, BLOBs, parameter buffers, and accessing database/server information.
3842"""
3943
4044from __future__ import annotations
@@ -296,7 +300,7 @@ def temp_database(*args, **kwargs) -> Connection:
296300
297301# Managers for Parameter buffers
298302class TPB : # pylint: disable=R0902
299- """Transaction Parameter Buffer .
303+ """Helper class to build and parse Transaction Parameter Buffers (TPB) used when starting transactions .
300304 """
301305 def __init__ (self , * , access_mode : TraAccessMode = TraAccessMode .WRITE ,
302306 isolation : Isolation = Isolation .SNAPSHOT ,
@@ -412,7 +416,7 @@ def reserve_table(self, name: str, share_mode: TableShareMode, access_mode: Tabl
412416 self ._table_reservation .append ((name , share_mode , access_mode ))
413417
414418class DPB :
415- """Database Parameter Buffer .
419+ """Helper class to build and parse Database Parameter Buffers (DPB) used when connecting databases .
416420 """
417421 def __init__ (self , * , user : str = None , password : str = None , role : str = None ,
418422 trusted_auth : bool = False , sql_dialect : int = 3 , timeout : int = None ,
@@ -684,7 +688,8 @@ def get_buffer(self, *, for_create: bool = False) -> bytes:
684688 return result
685689
686690class SPB_ATTACH :
687- """Service Parameter Buffer.
691+ """Helper class to build and parse Service Parameter Buffers (SPB) used when connecting
692+ to service manager.
688693 """
689694 def __init__ (self , * , user : str = None , password : str = None , trusted_auth : bool = False ,
690695 config : str = None , auth_plugin_list : str = None , expected_db : str = None ,
@@ -1106,6 +1111,9 @@ def get_engine_version(self, con: Connection | Server) -> float:
11061111class DatabaseInfoProvider3 (InfoProvider ):
11071112 """Provides access to information about attached database [Firebird 3+].
11081113
1114+ Information can be accessed either via specific properties (preferred) or the lower-level
1115+ `get_info()` method.
1116+
11091117 Important:
11101118 Do NOT create instances of this class directly! Use `Connection.info` property to
11111119 access the instance already bound to attached database.
@@ -1316,6 +1324,13 @@ def get_info(self, info_code: DbInfoCode, page_number: int=None) -> Any:
13161324
13171325 Returns:
13181326 The data type of returned value depends on information required.
1327+
1328+ Note:
1329+ Info codes that return stable values are cached on first call, so subsequent calls do not
1330+ access the server. These codes are: `CREATION_DATE`, `DB_CLASS`, `DB_PROVIDER`,
1331+ `DB_SQL_DIALECT`, `ODS_MINOR_VERSION`, `ODS_VERSION`, `PAGE_SIZE`, `VERSION`,
1332+ `FIREBIRD_VERSION`, `IMPLEMENTATION_OLD`, `IMPLEMENTATION`, `DB_ID`, `BASE_LEVEL`,
1333+ and `ATTACHMENT_ID`.
13191334 """
13201335 if info_code in self ._cache :
13211336 return self ._cache [info_code ]
@@ -1589,6 +1604,9 @@ def engine_version(self) -> float:
15891604class DatabaseInfoProvider (DatabaseInfoProvider3 ):
15901605 """Provides access to information about attached database [Firebird 4+].
15911606
1607+ Information can be accessed either via specific properties (preferred) or the lower-level
1608+ `get_info()` method.
1609+
15921610 Important:
15931611 Do NOT create instances of this class directly! Use `Connection.info` property to
15941612 access the instance already bound to attached database.
@@ -1754,6 +1772,7 @@ def _prepare(self, sql: str, tra: TransactionManager) -> Statement:
17541772 tra .commit ()
17551773 return result
17561774 def _determine_field_precision (self , meta : ItemMetadata ) -> int :
1775+ # This internal method involve database queries using _tra_qry.
17571776 if (not meta .relation ) or (not meta .field ):
17581777 # Either or both field name and relation name are not provided,
17591778 # so we cannot determine field precision. It's normal situation
@@ -1796,6 +1815,7 @@ def _determine_field_precision(self, meta: ItemMetadata) -> int:
17961815 # We ran out of options
17971816 return 0
17981817 def _get_array_sqlsubtype (self , relation : bytes , column : bytes ) -> int | None :
1818+ # This internal method involve database query using _tra_qry.
17991819 subtype = self .__sqlsubtype_cache .get ((relation , column ))
18001820 if subtype is not None :
18011821 return subtype
@@ -1820,6 +1840,9 @@ def drop_database(self) -> None:
18201840 Closes all event collectors, transaction managers (with rollback) and statements
18211841 associated with this connection before attempt to drop the database.
18221842
1843+ Important:
1844+ The connection object becomes unusable after this call.
1845+
18231846 Hooks:
18241847 Event `.ConnectionHook.DROPPED`: Executed after database is sucessfuly dropped.
18251848 Hook must have signature::
@@ -2021,7 +2044,7 @@ def transactions(self) -> list[TransactionManager]:
20212044 return result
20222045 @property
20232046 def schema (self ) -> 'firebird.lib.schema.Schema' :
2024- """Access to database schema. Requires firebird.lib package.
2047+ """Access to database schema. Requires ` firebird.lib` package.
20252048 """
20262049 if self .__schema is None :
20272050 import firebird .lib .schema # pylint: disable=C0415
@@ -2031,7 +2054,7 @@ def schema(self) -> 'firebird.lib.schema.Schema':
20312054 return self .__schema
20322055 @property
20332056 def monitor (self ) -> 'firebird.lib.monitor.Monitor' :
2034- """Access to database monitoring tables. Requires firebird.lib package.
2057+ """Access to database monitoring tables. Requires ` firebird.lib` package.
20352058 """
20362059 if self .__monitor is None :
20372060 import firebird .lib .monitor # pylint: disable=C0415
@@ -2283,6 +2306,9 @@ def create_database(database: str | Path, *, user: str=None, password: str=None,
22832306class TransactionInfoProvider3 (InfoProvider ):
22842307 """Provides access to information about transaction [Firebird 3+].
22852308
2309+ Information can be accessed either via specific properties (preferred) or the lower-level
2310+ `get_info()` method.
2311+
22862312 Important:
22872313 Do NOT create instances of this class directly! Use `TransactionManager.info`
22882314 property to access the instance already bound to transaction context.
@@ -2392,6 +2418,9 @@ def snapshot_number(self) -> int:
23922418class TransactionInfoProvider (TransactionInfoProvider3 ):
23932419 """Provides access to information about transaction [Firebird 4+].
23942420
2421+ Information can be accessed either via specific properties (preferred) or the lower-level
2422+ `get_info()` method.
2423+
23952424 Important:
23962425 Do NOT create instances of this class directly! Use `TransactionManager.info`
23972426 property to access the instance already bound to transaction context.
@@ -2467,6 +2496,8 @@ def _get_handle(self) -> a.FB_API_HANDLE:
24672496 def close (self ) -> None :
24682497 """Close the transaction manager and release all associated resources.
24692498
2499+ Implicitly ends the current active transaction according to default_action (if active).
2500+
24702501 Important:
24712502 Closed instance SHALL NOT be used anymore.
24722503 """
@@ -3015,7 +3046,8 @@ def read(self, size: int=-1) -> str | bytes:
30153046 Like `file.read()`.
30163047
30173048 Note:
3018- Performs automatic conversion to `str` for TEXT BLOBs.
3049+ Performs automatic conversion to `str` for TEXT BLOBs (subtype 1) based on the
3050+ connection's encoding.
30193051 """
30203052 assert self ._blob is not None
30213053 if size >= 0 :
@@ -3195,6 +3227,7 @@ def __init__(self, connection: Connection, transaction: TransactionManager): # p
31953227 #: Names of columns that should be returned as `BlobReader`.
31963228 self .stream_blobs : list [str ] = []
31973229 #: BLOBs greater than threshold are returned as `BlobReader` instead in materialized form.
3230+ #: Defaults to the value from `driver_config`.
31983231 self .stream_blob_threshold = driver_config .stream_blob_threshold .value
31993232 def __enter__ (self ) -> Cursor :
32003233 return self
@@ -3930,7 +3963,7 @@ def executemany(self, operation: str | Statement,
39303963 Note:
39313964 This function simply calls `.execute` in a loop, feeding it with
39323965 parameters from `seq_of_parameters`. Because `.execute` reuses the statement,
3933- calling `executemany` is equally efective as direct use of prepared `Statement`
3966+ calling `executemany` is equally effective as direct use of prepared `Statement`
39343967 and calling `execute` in a loop directly in application.
39353968 """
39363969 for parameters in seq_of_parameters :
@@ -4075,7 +4108,7 @@ def to_dict(self, row: tuple, into: dict=None) -> dict:
40754108
40764109 Arguments:
40774110 row: Row data returned by fetch_* method.
4078- into: Dictionary that shouold be updated with row data.
4111+ into: Dictionary that should be updated with row data.
40794112 """
40804113 assert len (self ._stmt ._names ) == len (row ), "Length of data must match number of fields"
40814114 if into is None :
@@ -4216,6 +4249,9 @@ def name(self) -> str:
42164249class ServerInfoProvider (InfoProvider ):
42174250 """Provides access to information about attached server.
42184251
4252+ Information can be accessed either via specific properties (preferred) or the lower-level
4253+ `get_info()` method.
4254+
42194255 Important:
42204256 Do NOT create instances of this class directly! Use `Server.info` property to access
42214257 the instance already bound to connectected server.
@@ -5458,7 +5494,7 @@ def __init__(self, svc: iService, spb: bytes, host: str, encoding: str,
54585494 self .host : str = host
54595495 #: Service output mode (line or eof)
54605496 self .mode : SrvInfoCode = SrvInfoCode .TO_EOF
5461- #: Response buffer used to comunicate with service
5497+ #: Response buffer used to communicate with service
54625498 self .response : CBuffer = CBuffer (USHRT_MAX )
54635499 self ._eof : bool = False
54645500 self .__line_buffer : list [str ] = []
0 commit comments