2. API: Defaults Object
This object contains attributes that can be used to adjust the behavior of the python-oracledb driver.
All attributes are supported in Thin and Thick modes, subject to noted details.
An example of changing a default value is:
oracledb.defaults.fetch_lobs = False # return LOBs directly as strings or bytes
2.1. Defaults Attributes
This attribute has an initial value of 100.
The directory in which optional configuration files such as
tnsnames.orawill be read in python-oracledb Thin mode. This attribute takes its initial value from the environment variable
This attribute is not used by the python-oracledb Thick mode: the usual Oracle Client search path behavior for configuration files is followed, see Optional Oracle Net Configuration Files.
Identifies whether numbers should be fetched as decimal.Decimal values. This can help avoid issues with converting numbers from Oracle Database’s decimal format to Python’s binary format.
An output type handler such as previously required in cx_Oracle (see return_numbers_as_decimals.py) can alternatively be used to adjust the returned type. If a type handler exists and returns a variable (that is,
cursor.var(...)), then that return variable is used. If the type handler returns None, then the value of
oracledb.defaults.fetch_decimalsis used to determine whether to return
This attribute has an initial value of False.
When the value of this attribute is True, then queries to LOB columns return LOB locators. When the value of this attribute is False, then CLOBs and NCLOBs are fetched as strings, and BLOBs are fetched as bytes. If LOBs are larger than 1 GB, then this attribute should be set to True and the LOBs should be streamed. See Using CLOB and BLOB Data.
An output type handler such as the one previously required in cx_Oracle (see return_lobs_as_strings.py) can alternatively be used to adjust the returned type. If a type handler exists and returns a variable (that is, cursor.var(…)), then that return variable is used. If the type handler returns None, then the value of
The value of
oracledb.defaults.fetch_lobsdoes not affect LOBs returned as OUT binds.
This attribute has an initial value of True.
This attribute has an initial value of 2.