관리-도구
편집 파일: oracledb.cpython-38.pyc
U -?�f35 � @ sz d Z ddlmZ ddlZddlZddlmZ ddlmZ ddlm Z dd lmZ dd lmZ ddl mZ ddl mZ dd l mZ ddl mZ ddlmZ ddlmZ ddlmZ ddlmZ er�ddlmZ ddlmZ G dd� de j�ZG dd� de j�ZG dd� de�ZG dd� dee�Z G dd� de�Z!G dd � d ee!�Z"G d!d"� d"�Z#G d#d$� d$e�Z$G d%d&� d&e�Z%eZ&e%Z'dS )'a� .. dialect:: oracle+oracledb :name: python-oracledb :dbapi: oracledb :connectstring: oracle+oracledb://user:pass@hostname:port[/dbname][?service_name=<service>[&key=value&key=value...]] :url: https://oracle.github.io/python-oracledb/ Description ----------- python-oracledb is released by Oracle to supersede the cx_Oracle driver. It is fully compatible with cx_Oracle and features both a "thin" client mode that requires no dependencies, as well as a "thick" mode that uses the Oracle Client Interface in the same way as cx_Oracle. .. seealso:: :ref:`cx_oracle` - all of cx_Oracle's notes apply to the oracledb driver as well, with the exception that oracledb supports two phase transactions. The SQLAlchemy ``oracledb`` dialect provides both a sync and an async implementation under the same dialect name. The proper version is selected depending on how the engine is created: * calling :func:`_sa.create_engine` with ``oracle+oracledb://...`` will automatically select the sync version, e.g.:: from sqlalchemy import create_engine sync_engine = create_engine("oracle+oracledb://scott:tiger@localhost/?service_name=XEPDB1") * calling :func:`_asyncio.create_async_engine` with ``oracle+oracledb://...`` will automatically select the async version, e.g.:: from sqlalchemy.ext.asyncio import create_async_engine asyncio_engine = create_async_engine("oracle+oracledb://scott:tiger@localhost/?service_name=XEPDB1") The asyncio version of the dialect may also be specified explicitly using the ``oracledb_async`` suffix, as:: from sqlalchemy.ext.asyncio import create_async_engine asyncio_engine = create_async_engine("oracle+oracledb_async://scott:tiger@localhost/?service_name=XEPDB1") .. versionadded:: 2.0.25 added support for the async version of oracledb. Thick mode support ------------------ By default the ``python-oracledb`` is started in thin mode, that does not require oracle client libraries to be installed in the system. The ``python-oracledb`` driver also support a "thick" mode, that behaves similarly to ``cx_oracle`` and requires that Oracle Client Interface (OCI) is installed. To enable this mode, the user may call ``oracledb.init_oracle_client`` manually, or by passing the parameter ``thick_mode=True`` to :func:`_sa.create_engine`. To pass custom arguments to ``init_oracle_client``, like the ``lib_dir`` path, a dict may be passed to this parameter, as in:: engine = sa.create_engine("oracle+oracledb://...", thick_mode={ "lib_dir": "/path/to/oracle/client/lib", "driver_name": "my-app" }) .. seealso:: https://python-oracledb.readthedocs.io/en/latest/api_manual/module.html#oracledb.init_oracle_client Two Phase Transactions Supported -------------------------------- Two phase transactions are fully supported under oracledb. Starting with oracledb 2.3 two phase transactions are supported also in thin mode. APIs for two phase transactions are provided at the Core level via :meth:`_engine.Connection.begin_twophase` and :paramref:`_orm.Session.twophase` for transparent ORM use. .. versionchanged:: 2.0.32 added support for two phase transactions .. versionadded:: 2.0.0 added support for oracledb driver. � )�annotationsN)�Any)� TYPE_CHECKING� )� cx_oracle� )�exc)�pool)�AsyncAdapt_dbapi_connection)�AsyncAdapt_dbapi_cursor)�AsyncAdapt_dbapi_ss_cursor)�#AsyncAdaptFallback_dbapi_connection)�default)�asbool)�await_fallback)� await_only)�AsyncConnection)�AsyncCursorc @ s e Zd ZdS )�OracleExecutionContext_oracledbN)�__name__� __module__�__qualname__� r r �S/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/dialects/oracle/oracledb.pyr r s r c s� e Zd ZdZeZdZdZd� fdd� Ze dd� �Z e d d � �Ze dd� �Zd d� Z dd� Zdd� Zddd�Zddd�Zdd� Z� ZS )�OracleDialect_oracledbT�oracledb)r Nc sR t � j||||f|� | jd k rN|s.t|t�rNt|t�r<|ni }| jjf |� d S �N)�super�__init__Zdbapi� isinstance�dictZinit_oracle_client)�selfZauto_convert_lobsZcoerce_to_decimal� arraysizeZencoding_errorsZ thick_mode�kwargs�kw�� __class__r r r s �� ��zOracleDialect_oracledb.__init__c C s dd l }|S �Nr )r ��clsr r r r �import_dbapi� s z#OracleDialect_oracledb.import_dbapic C s |j jjS r )� connectionZdbapi_connection�thin)r) r+ r r r �is_thin_mode� s z#OracleDialect_oracledb.is_thin_modec C s t S r )�OracleDialectAsync_oracledb)r) �urlr r r �get_async_dialect_cls� s z,OracleDialect_oracledb.get_async_dialect_clsc C sn d}|d k r:t �d|j�}|r:tdd� |�ddd�D ��}|| _| jdkrj| j| jk rjt�d| j� d ���d S ) N)r r r z(\d+)\.(\d+)(?:\.(\d+))?c s s | ]}|d k rt |�V qd S r )�int)�.0�xr r r � <genexpr>� s z7OracleDialect_oracledb._load_version.<locals>.<genexpr>r � r zoracledb version z and above are supported) �re�match�version�tuple�groupZoracledb_ver�_min_versionr ZInvalidRequestError)r! Zdbapi_moduler8 �mr r r � _load_version� s �� ��z$OracleDialect_oracledb._load_versionc C s( |j j|� }|j �|� ||j jd<