
    +h                        d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddlm
Z
 ddlmZ d	d
lmZ d	dlmZ d	dlmZ d	dlmZ d	dlmZ d	dlmZ d	dlmZ  ej.                  d      Z e edd            Z G d dej8                        Z G d dej<                        Z G d de      Z  G d de ejB                        Z" G d de ejF                        Z$ G d de      Z% G d  d!ejL                        Z' G d" d#ejP                        Z) G d$ d%ejT                        Z+ G d& d'ejX                        Z- G d( d)ej\                        Z/ G d* d+ej`                        Z1 G d, d-ejd                        Z3 G d. d/ejh                        Z5 G d0 d1ejl                        Z7 G d2 d3ejp                        Z9 G d4 d5ejt                        Z; G d6 d7ejx                        Z= G d8 d9ej|                        Z? G d: d;ej                        ZA G d< d=ej                        ZC G d> d?e	      ZD G d@ dAe      ZE G dB dCe
      ZFeFZGy)DaL  
.. dialect:: oracle+cx_oracle
    :name: cx-Oracle
    :dbapi: cx_oracle
    :connectstring: oracle+cx_oracle://user:pass@hostname:port[/dbname][?service_name=<service>[&key=value&key=value...]]
    :url: https://oracle.github.io/python-cx_Oracle/

DSN vs. Hostname connections
-----------------------------

cx_Oracle provides several methods of indicating the target database.  The
dialect translates from a series of different URL forms.

Hostname Connections with Easy Connect Syntax
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Given a hostname, port and service name of the target Oracle Database, for
example from Oracle's `Easy Connect syntax
<https://cx-oracle.readthedocs.io/en/latest/user_guide/connection_handling.html#easy-connect-syntax-for-connection-strings>`_,
then connect in SQLAlchemy using the ``service_name`` query string parameter::

    engine = create_engine("oracle+cx_oracle://scott:tiger@hostname:port/?service_name=myservice&encoding=UTF-8&nencoding=UTF-8")

The `full Easy Connect syntax
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-B0437826-43C1-49EC-A94D-B650B6A4A6EE>`_
is not supported.  Instead, use a ``tnsnames.ora`` file and connect using a
DSN.

Connections with tnsnames.ora or Oracle Cloud
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Alternatively, if no port, database name, or ``service_name`` is provided, the
dialect will use an Oracle DSN "connection string".  This takes the "hostname"
portion of the URL as the data source name.  For example, if the
``tnsnames.ora`` file contains a `Net Service Name
<https://cx-oracle.readthedocs.io/en/latest/user_guide/connection_handling.html#net-service-names-for-connection-strings>`_
of ``myalias`` as below::

    myalias =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = mymachine.example.com)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = orclpdb1)
        )
      )

The cx_Oracle dialect connects to this database service when ``myalias`` is the
hostname portion of the URL, without specifying a port, database name or
``service_name``::

    engine = create_engine("oracle+cx_oracle://scott:tiger@myalias/?encoding=UTF-8&nencoding=UTF-8")

Users of Oracle Cloud should use this syntax and also configure the cloud
wallet as shown in cx_Oracle documentation `Connecting to Autononmous Databases
<https://cx-oracle.readthedocs.io/en/latest/user_guide/connection_handling.html#connecting-to-autononmous-databases>`_.

SID Connections
^^^^^^^^^^^^^^^

To use Oracle's obsolete SID connection syntax, the SID can be passed in a
"database name" portion of the URL as below::

    engine = create_engine("oracle+cx_oracle://scott:tiger@hostname:1521/dbname?encoding=UTF-8&nencoding=UTF-8")

Above, the DSN passed to cx_Oracle is created by ``cx_Oracle.makedsn()`` as
follows::

    >>> import cx_Oracle
    >>> cx_Oracle.makedsn("hostname", 1521, sid="dbname")
    '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=1521))(CONNECT_DATA=(SID=dbname)))'

Passing cx_Oracle connect arguments
-----------------------------------

Additional connection arguments can usually be passed via the URL
query string; particular symbols like ``cx_Oracle.SYSDBA`` are intercepted
and converted to the correct symbol::

    e = create_engine(
        "oracle+cx_oracle://user:pass@dsn?encoding=UTF-8&nencoding=UTF-8&mode=SYSDBA&events=true")

.. versionchanged:: 1.3 the cx_oracle dialect now accepts all argument names
   within the URL string itself, to be passed to the cx_Oracle DBAPI.   As
   was the case earlier but not correctly documented, the
   :paramref:`_sa.create_engine.connect_args` parameter also accepts all
   cx_Oracle DBAPI connect arguments.

To pass arguments directly to ``.connect()`` without using the query
string, use the :paramref:`_sa.create_engine.connect_args` dictionary.
Any cx_Oracle parameter value and/or constant may be passed, such as::

    import cx_Oracle
    e = create_engine(
        "oracle+cx_oracle://user:pass@dsn",
        connect_args={
            "encoding": "UTF-8",
            "nencoding": "UTF-8",
            "mode": cx_Oracle.SYSDBA,
            "events": True
        }
    )

Note that the default value for ``encoding`` and ``nencoding`` was changed to
"UTF-8" in cx_Oracle 8.0 so these parameters can be omitted when using that
version, or later.

Options consumed by the SQLAlchemy cx_Oracle dialect outside of the driver
--------------------------------------------------------------------------

There are also options that are consumed by the SQLAlchemy cx_oracle dialect
itself.  These options are always passed directly to :func:`_sa.create_engine`
, such as::

    e = create_engine(
        "oracle+cx_oracle://user:pass@dsn", coerce_to_unicode=False)

The parameters accepted by the cx_oracle dialect are as follows:

* ``arraysize`` - set the cx_oracle.arraysize value on cursors, defaulted
  to 50.  This setting is significant with cx_Oracle as the contents of LOB
  objects are only readable within a "live" row (e.g. within a batch of
  50 rows).

* ``auto_convert_lobs`` - defaults to True; See :ref:`cx_oracle_lob`.

* ``coerce_to_unicode`` - see :ref:`cx_oracle_unicode` for detail.

* ``coerce_to_decimal`` - see :ref:`cx_oracle_numeric` for detail.

* ``encoding_errors`` - see :ref:`cx_oracle_unicode_encoding_errors` for detail.

.. _cx_oracle_sessionpool:

Using cx_Oracle SessionPool
---------------------------

The cx_Oracle library provides its own connection pool implementation that may
be used in place of SQLAlchemy's pooling functionality.  This can be achieved
by using the :paramref:`_sa.create_engine.creator` parameter to provide a
function that returns a new connection, along with setting
:paramref:`_sa.create_engine.pool_class` to ``NullPool`` to disable
SQLAlchemy's pooling::

    import cx_Oracle
    from sqlalchemy import create_engine
    from sqlalchemy.pool import NullPool

    pool = cx_Oracle.SessionPool(
        user="scott", password="tiger", dsn="orclpdb",
        min=2, max=5, increment=1, threaded=True,
	encoding="UTF-8", nencoding="UTF-8"
    )

    engine = create_engine("oracle://", creator=pool.acquire, poolclass=NullPool)

The above engine may then be used normally where cx_Oracle's pool handles
connection pooling::

    with engine.connect() as conn:
        print(conn.scalar("select 1 FROM dual"))


As well as providing a scalable solution for multi-user applications, the
cx_Oracle session pool supports some Oracle features such as DRCP and
`Application Continuity
<https://cx-oracle.readthedocs.io/en/latest/user_guide/ha.html#application-continuity-ac>`_.

Using Oracle Database Resident Connection Pooling (DRCP)
--------------------------------------------------------

When using Oracle's `DRCP
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-015CA8C1-2386-4626-855D-CC546DDC1086>`_,
the best practice is to pass a connection class and "purity" when acquiring a
connection from the SessionPool.  Refer to the `cx_Oracle DRCP documentation
<https://cx-oracle.readthedocs.io/en/latest/user_guide/connection_handling.html#database-resident-connection-pooling-drcp>`_.

This can be achieved by wrapping ``pool.acquire()``::

    import cx_Oracle
    from sqlalchemy import create_engine
    from sqlalchemy.pool import NullPool

    pool = cx_Oracle.SessionPool(
        user="scott", password="tiger", dsn="orclpdb",
        min=2, max=5, increment=1, threaded=True,
	encoding="UTF-8", nencoding="UTF-8"
    )

    def creator():
        return pool.acquire(cclass="MYCLASS", purity=cx_Oracle.ATTR_PURITY_SELF)

    engine = create_engine("oracle://", creator=creator, poolclass=NullPool)

The above engine may then be used normally where cx_Oracle handles session
pooling and Oracle Database additionally uses DRCP::

    with engine.connect() as conn:
        print(conn.scalar("select 1 FROM dual"))

.. _cx_oracle_unicode:

Unicode
-------

As is the case for all DBAPIs under Python 3, all strings are inherently
Unicode strings.     Under Python 2, cx_Oracle also supports Python Unicode
objects directly.    In all cases however, the driver requires an explicit
encoding configuration.

Ensuring the Correct Client Encoding
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The long accepted standard for establishing client encoding for nearly all
Oracle related software is via the `NLS_LANG <https://www.oracle.com/database/technologies/faq-nls-lang.html>`_
environment variable.   cx_Oracle like most other Oracle drivers will use
this environment variable as the source of its encoding configuration.  The
format of this variable is idiosyncratic; a typical value would be
``AMERICAN_AMERICA.AL32UTF8``.

The cx_Oracle driver also supports a programmatic alternative which is to
pass the ``encoding`` and ``nencoding`` parameters directly to its
``.connect()`` function.  These can be present in the URL as follows::

    engine = create_engine("oracle+cx_oracle://scott:tiger@orclpdb/?encoding=UTF-8&nencoding=UTF-8")

For the meaning of the ``encoding`` and ``nencoding`` parameters, please
consult
`Characters Sets and National Language Support (NLS) <https://cx-oracle.readthedocs.io/en/latest/user_guide/globalization.html#globalization>`_.

.. seealso::

    `Characters Sets and National Language Support (NLS) <https://cx-oracle.readthedocs.io/en/latest/user_guide/globalization.html#globalization>`_
    - in the cx_Oracle documentation.


Unicode-specific Column datatypes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The Core expression language handles unicode data by use of the :class:`.Unicode`
and :class:`.UnicodeText`
datatypes.  These types correspond to the  VARCHAR2 and CLOB Oracle datatypes by
default.   When using these datatypes with Unicode data, it is expected that
the Oracle database is configured with a Unicode-aware character set, as well
as that the ``NLS_LANG`` environment variable is set appropriately, so that
the VARCHAR2 and CLOB datatypes can accommodate the data.

In the case that the Oracle database is not configured with a Unicode character
set, the two options are to use the :class:`_types.NCHAR` and
:class:`_oracle.NCLOB` datatypes explicitly, or to pass the flag
``use_nchar_for_unicode=True`` to :func:`_sa.create_engine`,
which will cause the
SQLAlchemy dialect to use NCHAR/NCLOB for the :class:`.Unicode` /
:class:`.UnicodeText` datatypes instead of VARCHAR/CLOB.

.. versionchanged:: 1.3  The :class:`.Unicode` and :class:`.UnicodeText`
   datatypes now correspond to the ``VARCHAR2`` and ``CLOB`` Oracle datatypes
   unless the ``use_nchar_for_unicode=True`` is passed to the dialect
   when :func:`_sa.create_engine` is called.

Unicode Coercion of result rows under Python 2
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

When result sets are fetched that include strings, under Python 3 the cx_Oracle
DBAPI returns all strings as Python Unicode objects, since Python 3 only has a
Unicode string type.  This occurs for data fetched from datatypes such as
VARCHAR2, CHAR, CLOB, NCHAR, NCLOB, etc.  In order to provide cross-
compatibility under Python 2, the SQLAlchemy cx_Oracle dialect will add
Unicode-conversion to string data under Python 2 as well.  Historically, this
made use of converters that were supplied by cx_Oracle but were found to be
non-performant; SQLAlchemy's own converters are used for the string to Unicode
conversion under Python 2.  To disable the Python 2 Unicode conversion for
VARCHAR2, CHAR, and CLOB, the flag ``coerce_to_unicode=False`` can be passed to
:func:`_sa.create_engine`.

.. versionchanged:: 1.3 Unicode conversion is applied to all string values
   by default under python 2.  The ``coerce_to_unicode`` now defaults to True
   and can be set to False to disable the Unicode coercion of strings that are
   delivered as VARCHAR2/CHAR/CLOB data.

.. _cx_oracle_unicode_encoding_errors:

Encoding Errors
^^^^^^^^^^^^^^^

For the unusual case that data in the Oracle database is present with a broken
encoding, the dialect accepts a parameter ``encoding_errors`` which will be
passed to Unicode decoding functions in order to affect how decoding errors are
handled.  The value is ultimately consumed by the Python `decode
<https://docs.python.org/3/library/stdtypes.html#bytes.decode>`_ function, and
is passed both via cx_Oracle's ``encodingErrors`` parameter consumed by
``Cursor.var()``, as well as SQLAlchemy's own decoding function, as the
cx_Oracle dialect makes use of both under different circumstances.

.. versionadded:: 1.3.11


.. _cx_oracle_setinputsizes:

Fine grained control over cx_Oracle data binding performance with setinputsizes
-------------------------------------------------------------------------------

The cx_Oracle DBAPI has a deep and fundamental reliance upon the usage of the
DBAPI ``setinputsizes()`` call.   The purpose of this call is to establish the
datatypes that are bound to a SQL statement for Python values being passed as
parameters.  While virtually no other DBAPI assigns any use to the
``setinputsizes()`` call, the cx_Oracle DBAPI relies upon it heavily in its
interactions with the Oracle client interface, and in some scenarios it is  not
possible for SQLAlchemy to know exactly how data should be bound, as some
settings can cause profoundly different performance characteristics, while
altering the type coercion behavior at the same time.

Users of the cx_Oracle dialect are **strongly encouraged** to read through
cx_Oracle's list of built-in datatype symbols at
https://cx-oracle.readthedocs.io/en/latest/api_manual/module.html#database-types.
Note that in some cases, significant performance degradation can occur when
using these types vs. not, in particular when specifying ``cx_Oracle.CLOB``.

On the SQLAlchemy side, the :meth:`.DialectEvents.do_setinputsizes` event can
be used both for runtime visibility (e.g. logging) of the setinputsizes step as
well as to fully control how ``setinputsizes()`` is used on a per-statement
basis.

.. versionadded:: 1.2.9 Added :meth:`.DialectEvents.setinputsizes`


Example 1 - logging all setinputsizes calls
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The following example illustrates how to log the intermediary values from a
SQLAlchemy perspective before they are converted to the raw ``setinputsizes()``
parameter dictionary.  The keys of the dictionary are :class:`.BindParameter`
objects which have a ``.key`` and a ``.type`` attribute::

    from sqlalchemy import create_engine, event

    engine = create_engine("oracle+cx_oracle://scott:tiger@host/xe")

    @event.listens_for(engine, "do_setinputsizes")
    def _log_setinputsizes(inputsizes, cursor, statement, parameters, context):
        for bindparam, dbapitype in inputsizes.items():
                log.info(
                    "Bound parameter name: %s  SQLAlchemy type: %r  "
                    "DBAPI object: %s",
                    bindparam.key, bindparam.type, dbapitype)

Example 2 - remove all bindings to CLOB
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The ``CLOB`` datatype in cx_Oracle incurs a significant performance overhead,
however is set by default for the ``Text`` type within the SQLAlchemy 1.2
series.   This setting can be modified as follows::

    from sqlalchemy import create_engine, event
    from cx_Oracle import CLOB

    engine = create_engine("oracle+cx_oracle://scott:tiger@host/xe")

    @event.listens_for(engine, "do_setinputsizes")
    def _remove_clob(inputsizes, cursor, statement, parameters, context):
        for bindparam, dbapitype in list(inputsizes.items()):
            if dbapitype is CLOB:
                del inputsizes[bindparam]

.. _cx_oracle_returning:

RETURNING Support
-----------------

The cx_Oracle dialect implements RETURNING using OUT parameters.
The dialect supports RETURNING fully, however cx_Oracle 6 is recommended
for complete support.

.. _cx_oracle_lob:

LOB Objects
-----------

cx_oracle returns oracle LOBs using the cx_oracle.LOB object.  SQLAlchemy
converts these to strings so that the interface of the Binary type is
consistent with that of other backends, which takes place within a cx_Oracle
outputtypehandler.

cx_Oracle prior to version 6 would require that LOB objects be read before
a new batch of rows would be read, as determined by the ``cursor.arraysize``.
As of the 6 series, this limitation has been lifted.  Nevertheless, because
SQLAlchemy pre-reads these LOBs up front, this issue is avoided in any case.

To disable the auto "read()" feature of the dialect, the flag
``auto_convert_lobs=False`` may be passed to :func:`_sa.create_engine`.  Under
the cx_Oracle 5 series, having this flag turned off means there is the chance
of reading from a stale LOB object if not read as it is fetched.   With
cx_Oracle 6, this issue is resolved.

.. versionchanged:: 1.2  the LOB handling system has been greatly simplified
   internally to make use of outputtypehandlers, and no longer makes use
   of alternate "buffered" result set objects.

Two Phase Transactions Not Supported
-------------------------------------

Two phase transactions are **not supported** under cx_Oracle due to poor
driver support.   As of cx_Oracle 6.0b1, the interface for
two phase transactions has been changed to be more of a direct pass-through
to the underlying OCI layer with less automation.  The additional logic
to support this system is not implemented in SQLAlchemy.

.. _cx_oracle_numeric:

Precision Numerics
------------------

SQLAlchemy's numeric types can handle receiving and returning values as Python
``Decimal`` objects or float objects.  When a :class:`.Numeric` object, or a
subclass such as :class:`.Float`, :class:`_oracle.DOUBLE_PRECISION` etc. is in
use, the :paramref:`.Numeric.asdecimal` flag determines if values should be
coerced to ``Decimal`` upon return, or returned as float objects.   To make
matters more complicated under Oracle, Oracle's ``NUMBER`` type can also
represent integer values if the "scale" is zero, so the Oracle-specific
:class:`_oracle.NUMBER` type takes this into account as well.

The cx_Oracle dialect makes extensive use of connection- and cursor-level
"outputtypehandler" callables in order to coerce numeric values as requested.
These callables are specific to the specific flavor of :class:`.Numeric` in
use, as well as if no SQLAlchemy typing objects are present.   There are
observed scenarios where Oracle may sends incomplete or ambiguous information
about the numeric types being returned, such as a query where the numeric types
are buried under multiple levels of subquery.  The type handlers do their best
to make the right decision in all cases, deferring to the underlying cx_Oracle
DBAPI for all those cases where the driver can make the best decision.

When no typing objects are present, as when executing plain SQL strings, a
default "outputtypehandler" is present which will generally return numeric
values which specify precision and scale as Python ``Decimal`` objects.  To
disable this coercion to decimal for performance reasons, pass the flag
``coerce_to_decimal=False`` to :func:`_sa.create_engine`::

    engine = create_engine("oracle+cx_oracle://dsn", coerce_to_decimal=False)

The ``coerce_to_decimal`` flag only impacts the results of plain string
SQL statements that are not otherwise associated with a :class:`.Numeric`
SQLAlchemy type (or a subclass of such).

.. versionchanged:: 1.2  The numeric handling system for cx_Oracle has been
   reworked to take advantage of newer cx_Oracle features as well
   as better integration of outputtypehandlers.

    )absolute_importN   )base)OracleCompiler)OracleDialect)OracleExecutionContext   )exc)
processors)types)util)cursor)
expression)compatz[%\(\):\[\]\.\/\? ]z
%():[]./? PAZCCCCCCCCc                       e Zd Zd Zd Zd Zy)_OracleIntegerc                     t         S Nintselfdbapis     W/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/dialects/oracle/cx_oracle.pyget_dbapi_typez_OracleInteger.get_dbapi_type  s	     
    c                 t    |j                   }|j                  |j                  d|j                  t              S )N   	arraysizeoutconverter)r   varSTRINGr!   r   )r   dialectr   	cx_Oracles       r   _cx_oracle_varz_OracleInteger._cx_oracle_var  s6    MM	zzcV-=-=C  
 	
r   c                       fd}|S )Nc                 (    j                  |       S r   )r'   )r   namedefault_typesize	precisionscaler%   r   s         r   handlerz<_OracleInteger._cx_oracle_outputtypehandler.<locals>.handler  s    &&w77r    )r   r%   r/   s   `` r   _cx_oracle_outputtypehandlerz+_OracleInteger._cx_oracle_outputtypehandler  s    	8 r   N)__name__
__module____qualname__r   r'   r1   r0   r   r   r   r     s    

r   r   c                   "    e Zd ZdZd Zd Zd Zy)_OracleNumericFc                     | j                   dk(  ry | j                  r5t        j                  t        j
                  | j                        fd}|S t        j                  S )Nr   c                 ~    t        | t        t        f      r |       S | | j                         rt        |       S | S r   )
isinstancer   floatis_infinite)value	processors    r   processz._OracleNumeric.bind_processor.<locals>.process  s<    ec5\2$U++&5+<+<+> <' Lr   )r.   	asdecimalr   to_decimal_processor_factorydecimalDecimal_effective_decimal_return_scaleto_float)r   r%   r>   r=   s      @r   bind_processorz_OracleNumeric.bind_processor  sO    ::?^^"??!E!EI! N&&&r   c                      y r   r0   )r   r%   coltypes      r   result_processorz_OracleNumeric.result_processor      r   c                 N     j                   j                   fd}|S )Nc                 ,   d }|ryj                   rN|j                  k(  r|}t        j                  }nÉ
rt        j                  }nj                  }	j
                  }nj                  r|dk(  ry j                  }nxj                   rN|j                  k(  r|}t        j                  }nJ
rt        j                  }n7j                  }	j
                  }nj                  r|dk(  ry j                  }| j                  |d| j                  |      S )Nr   r   r    )	r?   NATIVE_FLOATrA   rB   r$   _to_decimal	is_numberr#   r!   )r   r*   r+   r,   r-   r.   r"   type_r&   r%   is_cx_oracle_6r   s           r   r/   z<_OracleNumeric._cx_oracle_outputtypehandler.<locals>.handler  s    L>>#y'='== !-'.' ' ) 0 0'.':':~~%1*  $ ) 6 6 >>#y'='== ,'.' ' ) 0 0'.':':~~%1*  $ ) 6 6:: **)	   r   )r   _is_cx_oracle_6)r   r%   r/   r&   rP   s   `` @@r   r1   z+_OracleNumeric._cx_oracle_outputtypehandler  s$    MM	 000	d r   N)r2   r3   r4   rN   rE   rH   r1   r0   r   r   r6   r6     s    I'(7r   r6   c                       e Zd Zd Zy)_OracleBinaryFloatc                     |j                   S r   )rL   r   s     r   r   z!_OracleBinaryFloat.get_dbapi_typeL  s    !!!r   Nr2   r3   r4   r   r0   r   r   rS   rS   K  s    "r   rS   c                       e Zd Zy)_OracleBINARY_FLOATNr2   r3   r4   r0   r   r   rW   rW   P      r   rW   c                       e Zd Zy)_OracleBINARY_DOUBLENrX   r0   r   r   r[   r[   T  rY   r   r[   c                       e Zd ZdZy)_OracleNUMBERTN)r2   r3   r4   rN   r0   r   r   r]   r]   X  s    Ir   r]   c                       e Zd Zd Zd Zy)_OracleDatec                      y r   r0   r   r%   s     r   rE   z_OracleDate.bind_processor]  rI   r   c                     d }|S )Nc                 *    | | j                         S | S r   )dater<   s    r   r>   z-_OracleDate.result_processor.<locals>.processa  s     zz|#r   r0   )r   r%   rG   r>   s       r   rH   z_OracleDate.result_processor`  s    	 r   N)r2   r3   r4   rE   rH   r0   r   r   r_   r_   \  s    r   r_   c                       e Zd Zd Zy)_OracleCharc                     |j                   S r   )
FIXED_CHARr   s     r   r   z_OracleChar.get_dbapi_typem  s    r   NrU   r0   r   r   rg   rg   l  s     r   rg   c                       e Zd Zd Zy)_OracleNCharc                     |j                   S r   )FIXED_NCHARr   s     r   r   z_OracleNChar.get_dbapi_typer         r   NrU   r0   r   r   rk   rk   q      !r   rk   c                       e Zd Zd Zy)_OracleUnicodeStringNCHARc                     |j                   S r   )NCHARr   s     r   r   z(_OracleUnicodeStringNCHAR.get_dbapi_typew      {{r   NrU   r0   r   r   rq   rq   v      r   rq   c                       e Zd Zd Zy)_OracleUnicodeStringCHARc                     |j                   S r   LONG_STRINGr   s     r   r   z'_OracleUnicodeStringCHAR.get_dbapi_type|  rn   r   NrU   r0   r   r   rw   rw   {  ro   r   rw   c                       e Zd Zd Zy)_OracleUnicodeTextNCLOBc                     |j                   S r   )NCLOBr   s     r   r   z&_OracleUnicodeTextNCLOB.get_dbapi_type  rt   r   NrU   r0   r   r   r|   r|     ru   r   r|   c                       e Zd Zd Zy)_OracleUnicodeTextCLOBc                     |j                   S r   CLOBr   s     r   r   z%_OracleUnicodeTextCLOB.get_dbapi_type      zzr   NrU   r0   r   r   r   r         r   r   c                       e Zd Zd Zy)_OracleTextc                     |j                   S r   r   r   s     r   r   z_OracleText.get_dbapi_type  r   r   NrU   r0   r   r   r   r     r   r   r   c                       e Zd Zd Zy)_OracleLongc                     |j                   S r   ry   r   s     r   r   z_OracleLong.get_dbapi_type  rn   r   NrU   r0   r   r   r   r     ro   r   r   c                       e Zd Zy)_OracleStringNrX   r0   r   r   r   r     rY   r   r   c                       e Zd Zd Zy)_OracleEnumc                 R    t         j                  j                  | |      fd}|S )Nc                      |       }|S r   r0   )r<   raw_str	enum_procs     r   r>   z+_OracleEnum.bind_processor.<locals>.process  s    &GNr   )sqltypesEnumrE   )r   r%   r>   r   s      @r   rE   z_OracleEnum.bind_processor  s%    MM00w?		 r   N)r2   r3   r4   rE   r0   r   r   r   r     s    r   r   c                   *     e Zd Zd Zd Z fdZ xZS )_OracleBinaryc                     |j                   S r   )BLOBr   s     r   r   z_OracleBinary.get_dbapi_type  r   r   c                      y r   r0   ra   s     r   rE   z_OracleBinary.bind_processor  rI   r   c                 F    |j                   sy t        t        |   ||      S r   )auto_convert_lobssuperr   rH   )r   r%   rG   	__class__s      r   rH   z_OracleBinary.result_processor  s(    ((> r   )r2   r3   r4   r   rE   rH   __classcell__r   s   @r   r   r     s     r   r   c                       e Zd Zd Zy)_OracleIntervalc                     |j                   S r   )INTERVALr   s     r   r   z_OracleInterval.get_dbapi_type  s    ~~r   NrU   r0   r   r   r   r     s    r   r   c                       e Zd Zy)
_OracleRawNrX   r0   r   r   r   r     rY   r   r   c                       e Zd Zd Zy)_OracleRowidc                     |j                   S r   )ROWIDr   s     r   r   z_OracleRowid.get_dbapi_type  rt   r   NrU   r0   r   r   r   r     ru   r   r   c                       e Zd ZdZd Zy)OracleCompiler_cx_oracleTc                    t        |dd       }|du s1|durP| j                  j                  |      r5|j                  dd      s#d|z  }||d<   |}t	        j
                  | |fi |S |j                  dd       }|s{t        j                  |      r?t        j                  d |      }|d   j                         s|d   d	k(  rd
|z   }||d<   |}n'|d   j                         s|d   d	k(  rd
|z   }||d<   |}t	        j
                  | |fi |S )NquoteTFpost_compilez"%s"escaped_fromc                 2    t         | j                  d         S Nr   )_ORACLE_BIND_TRANSLATE_CHARSgroup)ms    r   <lambda>z;OracleCompiler_cx_oracle.bindparam_string.<locals>.<lambda>  s    :1771:F r   r   _D)
getattrpreparer_bindparam_requires_quotesgetr   bindparam_string_ORACLE_BIND_TRANSLATE_REsearchsubisdigit)r   r*   kwr   quoted_namer   new_names          r   r   z)OracleCompiler_cx_oracle.bindparam_string  s+   gt,TME!88>
 FF>51 !4-K!%B~D!224DDD vvnd3(//5 588F A;&&(HQK3,>"X~H%)>"a"d1gn:%)>"..tT@R@@r   N)r2   r3   r4   _oracle_cx_sql_compilerr   r0   r   r   r   r     s    ",Ar   r   c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y)	 OracleExecutionContext_cx_oracleNc                 ~   | j                   j                  s| j                   j                  r| j                   j                  }| j                   j                  j                         D ]  }|j                  s| j                   j                  |   }|j                  j                  | j                        }t        |d      r5|j                  | j                  | j                        | j                  |<   n|j                  | j                  j                         }| j                  j                   }|0t#        j$                  d|j&                  d|j                  d      t(        j*                  r||j,                  |j.                  fv rnt1        j2                  | j                  j4                  | j                  j6                        | j                  j9                  |fd      | j                  |<   n||j:                  |j,                  |j.                  fv r,| j                  j9                  |d       | j                  |<   nt(        j*                  rt=        |t>        j@                        rjt1        j2                  | j                  j4                  | j                  j6                        | j                  j9                  |      | j                  |<   n(| j                  j9                  |      | j                  |<   | j                  |   | jB                  d	   |jE                  ||      <    y y )
Nr'   z*Cannot create out parameter for parameter z - its type z is not supported by cx_oracleerrorsc                 0     | j                               S r   read)r<   r"   s    r   r   zOOracleExecutionContext_cx_oracle._generate_out_parameter_vars.<locals>.<lambda>  s    <$)JJL<" r   r"   c                 "    | j                         S r   r   re   s    r   r   zOOracleExecutionContext_cx_oracle._generate_out_parameter_vars.<locals>.<lambda>(  s    5::< r   r   )#compiled	returninghas_out_parametersescaped_bind_namesbindsvalues
isoutparam
bind_namestypedialect_implr%   hasattrr'   r   out_parametersr   r   r
   InvalidRequestErrorkeyr   py2kr   r~   r   to_unicode_processor_factoryencodingencoding_errorsr#   r   r9   r   Unicode
parametersr   )r   quoted_bind_names	bindparamr*   	type_impldbtyper&   r"   s          @r   _generate_out_parameter_varsz=OracleExecutionContext_cx_oracle._generate_out_parameter_vars  s    ==""dmm&F&F $ @ @!]]00779 ?2	''==33I>D ) ; ;DLL IIy*:;4=4L4L LL$++5++D1 "+!9!9$,,:L:L!M$(LL$6$6	!>"%"9"9 1:y~~!O#  ";;6%NN%OO6 ,
 !+ G G$(LL$9$9+/<<+G+G!" ) 9= &." 9H 9D//5 $%NN%NN%OO( 
 9= &5O 9H 9D//5 $[[Z%x'7'7. !+ G G$(LL$9$9+/<<+G+G!" ) 9= &\ 9H 9D//5 9=8OD//5 ++D1 OOA&)--dD9{?2 'Gr   c                 @  	 i 	| j                   j                  D ]Q  \  }}}}|j                  | j                  d| j                        }|s2| j                  j                  |      }|	|<   S 	r.| j                  j                  	fd}|| j                  _        y y )Ncx_oracle_outputtypehandlerc                 F    |v r |   | |||||      S  | |||||      S r   r0   )r   r*   r+   r,   r-   r.   default_handleroutput_handlerss         r   output_type_handlerzaOracleExecutionContext_cx_oracle._generate_cursor_outputtype_handler.<locals>.output_type_handlerM  sJ     ?*0?40lD)U  +lD)U r   )	r   _result_columns_cached_custom_processorr%   _get_cx_oracle_type_handlerdenormalize_name_dbapi_connectionoutputtypehandlerr   )
r   keynamer*   objectsrO   r/   denormalized_namer   r   r   s
           @@r   #_generate_cursor_outputtype_handlerzDOracleExecutionContext_cx_oracle._generate_cursor_outputtype_handler<  s    /3}}/L/L 		=+WdGU44-00G $(LL$A$A'$J!5< 12		= "44FFO
 -@DKK) r   c                 R    t        |d      r|j                  | j                        S y )Nr1   )r   r1   r%   )r   impls     r   r   z<OracleExecutionContext_cx_oracle._get_cx_oracle_type_handler[  s%    47844T\\BBr   c                     t        | j                  dd      sy i | _        | j                          | j	                          | j
                  j                  | _        y )Nr   F)r   r   r   r   r   r%   _include_setinputsizesinclude_set_input_sizesr   s    r   pre_execz)OracleExecutionContext_cx_oracle.pre_execa  sH    t}}&?G ))+002'+||'J'J$r   c                     | j                   r| j                  r| j                   j                  rt        t	        | j                              D cg c]-  }| j
                  j                  | j                  d|z           / }}t        j                  | j                  t        j                  | j                   j                        D cg c]  }t        |d|j                        d f c}t        |      g      }|| _        y y y y c c}w c c}w )Nzret_%dr*   )initial_buffer)r   r   r   rangelenr%   _returningval_cursor FullyBufferedCursorFetchStrategyr   r   _select_iterablesr   _anon_name_labeltuplecursor_fetch_strategy)r   ireturning_paramscolfetch_strategys        r   	post_execz*OracleExecutionContext_cx_oracle.post_execm  s    ==T00T]]5L5L s4#6#678  **4+>+>x!|+LM   
 %EE  *;;//  S&#*>*>?F !&&6 78	N *8D&' 6M0= s   2D D
c                     | j                   j                         }| j                  j                  r| j                  j                  |_        |S r   )r   r   r%   r!   )r   cs     r   create_cursorz.OracleExecutionContext_cx_oracle.create_cursor  s9    ""))+<<!!,,00AKr   c                     | j                   j                  rJ |D cg c]*  }| j                  j                  | j                  |         , c}S c c}w r   )r   r   r%   	_paramvalr   )r   out_param_namesr*   s      r   get_out_parameter_valuesz9OracleExecutionContext_cx_oracle.get_out_parameter_values  sS     ==**** (
 LL""4#6#6t#<=
 	
 
s   /A)r2   r3   r4   r   r   r   r   r   r  r  r  r0   r   r   r   r     s.    ND2L@>
K8,	
r   r   c                       e Zd ZdZeZeZdZdZ	dZ
dZdZdZi ej                  eej"                  eej&                  eej*                  eej.                  eej2                  eej6                  eej:                  eej>                  ej@                  ejB                  e"ejF                  e"ejH                  e%ejL                  e'ejP                  e)ejT                  e+ejX                  e-ej\                  e/ej`                  e1ejd                  e3ejh                  e5ejl                  e7ejp                  e9ejt                  e;iZ<e=Z>dZ? e@j                  d      	 	 	 	 	 	 dd       ZBeCd        ZDd ZEeFd	        ZG fd
ZHd ZId ZJd ZKd ZLeMj                  ZOd ZPd ZQd ZRd ZSd ZTd ZUddZVd ZWd ZX	 ddZY	 ddZZd Z[d Z\ xZ]S )OracleDialect_cx_oracleT	cx_oracleN)1.3a8  The 'threaded' parameter to the cx_oracle dialect is deprecated as a dialect-level argument, and will be removed in a future release.  As of version 1.3, it defaults to False rather than True.  The 'threaded' option can be passed to cx_Oracle directly in the URL query string passed to :func:`_sa.create_engine`.)threadedc                    t        j                  | fi | || _        || _        ||| _        || _        || _        || _        | j                  ra| j                  j                         | _	        t        | j                  t        j                  <   t        | j                  t        j                  <   | j                   }|i | _        d| _        n!| j'                  |j(                        | _        | j$                  dk  r$| j$                  dkD  rt+        j,                  d      |j.                  |j0                  |j2                  |j4                  |j6                  |j8                  |j:                  |j<                  |j>                  t@        tB        tD        h| _        d | _#        | j$                  dk\  | _$        | jH                  rd|jJ                  _&        d }	|	| _'        n| jF                  | _'        | j$                  dk\  | _(        y )	Nr   r   r   )      z-cx_Oracle version 5.2 and above are supportedc                 "    | j                         S r   )getvaluere   s    r   r   z2OracleDialect_cx_oracle.__init__.<locals>.<lambda>  s    5>>+; r   )   r	   Tc                 F    	 | j                   d   d   S # t        $ r Y y w xY wr   )r   
IndexErrorre   s    r   r  z7OracleDialect_cx_oracle.__init__.<locals>._returningval	  s,    $$||Aq11% $#$s    	  )r"  ))r   __init__r!   r   _cx_oracle_threadedr   coerce_to_unicodecoerce_to_decimal_use_nchar_for_unicodecolspecscopyrq   r   r   r|   UnicodeTextr   r   cx_oracle_ver_parse_cx_oracle_verversionr
   r   DATETIMEr~   r   LOBrs   rm   r   ri   	TIMESTAMPr   rW   r[   r  _values_are_lists
__future__dml_ret_array_valr  rQ   )
r   r   r'  r(  r!   r   r  kwargsr&   r  s
             r   r%  z OracleDialect_cx_oracle.__init__  s   , 	t.v.".'/D$!2!2!2&& MM..0DM.GDMM(**+2IDMM(../JJ	*,D'!*D!%!:!:9;L;L!MD!!F*t/A/AI/M--C 
 ""%%$$###$+D' <DN &*%7%76%AD"%%9=	$$6$ &3"%)^^"#11T9r   c                     | j                   r@| j                  dk\  rd| j                   iS t        j                  d| j                  d       i S )N)r"     encodingErrorszcx_oracle version z  does not support encodingErrors)r   r-  r   warnr   s    r   _cursor_var_unicode_kwargsz2OracleDialect_cx_oracle._cursor_var_unicode_kwargs  sK    !!V+($*>*>??		)),
 	r   c                 z    t        j                  d|      }|r#t        d |j                  ddd      D              S y)Nz(\d+)\.(\d+)(?:\.(\d+))?c              3   8   K   | ]  }|t        |        y wr   r   .0xs     r   	<genexpr>z?OracleDialect_cx_oracle._parse_cx_oracle_ver.<locals>.<genexpr>%  s     KAQ]QKs   r   r  r	   r  )rematchr	  r   )r   r/  r   s      r   r.  z,OracleDialect_cx_oracle._parse_cx_oracle_ver"  s7    HH0':KAq)9KKKr   c                     dd l }|S r   )r&   )clsr&   s     r   r   zOracleDialect_cx_oracle.dbapi)  s    r   c                 t    t         t        |   |       | j                  rd| _        | j                  |       y )NF)r   r  
initialize_is_oracle_8supports_unicode_binds_detect_decimal_char)r   
connectionr   s     r   rG  z"OracleDialect_cx_oracle.initialize/  s2    %t7
C*/D'!!*-r   c                 t   |j                         5 }|j                  t              }|j                  dd|i       |j	                         }|j                  dd      \  }}}|j                  d|||d       |j                         }|t        j                  d      |d   }	d d d        |	S # 1 sw Y   	S xY w)	Nz
                begin
                   :trans_id := dbms_transaction.local_transaction_id( TRUE );
                end;
                trans_id.r  zSELECT CASE BITAND(t.flag, POWER(2, 28)) WHEN 0 THEN 'READ COMMITTED' ELSE 'SERIALIZABLE' END AS isolation_level FROM v$transaction t WHERE (t.xidusn, t.xidslot, t.xidsqn) = ((:xidusn, :xidslot, :xidsqn)))xidusnxidslotxidsqnz"could not retrieve isolation levelr   )	r   r#   strexecuter!  splitfetchoner
   r   )
r   rK  r   outvalrM  rO  rP  rQ  rowresults
             r   get_isolation_levelz+OracleDialect_cx_oracle.get_isolation_level6  s       	F
 ZZ_FNN
 V$ (H&.nnS!&<#FGVNN1 "gH //#C{--8  VF?	B C	B s   BB--B7c                     t        |d      r|j                  }n|}|dk(  rd|_        y d|_        |j                          |j	                         5 }|j                  d|z         d d d        y # 1 sw Y   y xY w)Ndbapi_connection
AUTOCOMMITTFz$ALTER SESSION SET ISOLATION_LEVEL=%s)r   r[  
autocommitrollbackr   rS  )r   rK  levelr[  r   s        r   set_isolation_levelz+OracleDialect_cx_oracle.set_isolation_levele  s~    :12)::)L *.'*/'!""$ OEMNO O Os   A..A7c                     |j                   }|j                         5 } fd}||_        |j                  d       |j	                         d   }|j                  d      d   }|d   j                         rJ 	 d d d         _         j                  dk7  r/ j                   j                   fd _         fd _	        y y # 1 sw Y   OxY w)	Nc                 h    | j                  j                  j                  d| j                        S )Nr   )r!   )r#   r   r$   r!   )r   r*   defaultTyper,   r-   r.   r   s         r   r   zIOracleDialect_cx_oracle._detect_decimal_char.<locals>.output_type_handler  s2     zzJJ%%sf6F6F "  r   zSELECT 1.1 FROM DUALr   0r   rN  c                 H     | j                  j                  d            S NrN  replace_decimal_char)r<   _detect_decimalr   s    r   r   z>OracleDialect_cx_oracle._detect_decimal_char.<locals>.<lambda>  s     d00#62 r   c                 H     | j                  j                  d            S rf  rg  )r<   rM   r   s    r   r   z>OracleDialect_cx_oracle._detect_decimal_char.<locals>.<lambda>  s     [d00#6. r   )
rK  r   r   rS  rU  lstripr   ri  rj  rM   )	r   rK  r[  r   r   r<   decimal_charrj  rM   s	   `      @@r   rJ  z,OracleDialect_cx_oracle._detect_decimal_charr  s     &00$$& 	1& (;F$NN12OO%a(E <<,Q/L#A..0000+	1. *$"22O**K$D  D %3	1 	1s   AC		Cc                 B    d|v r| j                  |      S t        |      S rf  )rM   r   )r   r<   s     r   rj  z'OracleDialect_cx_oracle._detect_decimal  s$    %<##E**u:r   c                     | j                   t        d      j                        t        d      j                        fd}|S )z^establish the default outputtypehandler established at the
        connection level.

        T)r?   Fc                    |j                   k(  rx|j                  urjj                  sy |dk(  r7|dv r3| j                  j                  dj
                  | j                        S |r|dkD  r 
| |||||      S  	| |||||      S j                  r|j                  j                  fv r|j                  ur|j                  urt        j                  rTt        j                  j                  j                         }| j                  j                  || j                  |      S  | j                  t"        j$                  || j                  fi j&                  S j(                  r|j                  j                  fv rt        j                  rTt        j                  j                  j                         }| j                  j*                  || j                  |      S  | j                  j*                  || j                  fi j&                  S j(                  r7|j,                  fv r'| j                  j.                  || j                        S y y )Nr   )r   ir   )r"   r!   r   r   )NUMBERrL   r(  r#   r$   rj  r!   r'  ri   r   r~   r   r   r   r   r   r   r   	text_typer;  r   rz   r   LONG_BINARY)r   r*   r+   r,   r-   r.   r"   r&   r%   float_handlernumber_handlers          r   r   z\OracleDialect_cx_oracle._generate_connection_outputtype_handler.<locals>.output_type_handler  s   
 	 0 00 	(>(>>00!^(: "::!((%,%<%<"("2"2	 &   519)lD)U  )lD)U  )) $$((
 !	6 	7;;#-#J#J((1H1H$L "::!((((%1	 &   &6::(( "<<	  **|@ 0 ;;#-#J#J((1H1H$L "::!--((%1	 &   &6::!--(( "<<	  **|@ 0 zz))$$ 0*r   )r   r]   r1   )r   r   r&   r%   rt  ru  s     @@@@r   '_generate_connection_outputtype_handlerz?OracleDialect_cx_oracle._generate_connection_outputtype_handler  sZ     MM	&

&
&w
/ 	 &

&
&w
/ 	V	p #"r   c                 2    | j                         fd}|S )Nc                     | _         y r   )r   )connr   s    r   
on_connectz6OracleDialect_cx_oracle.on_connect.<locals>.on_connect  s    %8D"r   )rv  )r   rz  r   s     @r   rz  z"OracleDialect_cx_oracle.on_connect  s    "JJL	9 r   c                     t        |j                        }dD ]X  }||v st        j                  d|z  d       t        j                  ||t
               t         ||j                  |             Z |j                  }|j                  dd       }|s|rj|j                  }|rt        |      }nd}|r|rt        j                  d      |rd|i}|rd|i}  j                  j                  |j                  |fi }n|j                  }|||d	<   |j                   |j                   |d
<   |j"                  |j"                  |d<    j$                  |j'                  d j$                          fd}	t        j                  |d|	       t        j                  |dt
               t        j                  |dt
               t        j                  |d|	       g |fS )N)use_ansir   zfcx_oracle dialect option %r should only be passed to create_engine directly, not within the URL stringr  )r/  service_namei  zI"service_name" option shouldn't be used with a "database" part of the urlsiddsnpassworduserr  c                     t        | t        j                        r	 t        |       }|S | S # t        $ r) | j                         } t        j                  |       cY S w xY wr   )r9   r   string_typesr   
ValueErrorupperr   r   )r<   int_valr   s     r   convert_cx_oracle_constantzOOracleDialect_cx_oracle.create_connect_args.<locals>.convert_cx_oracle_constantJ  sZ    %!2!23#!%jG
 #N " 6!KKME"4::u556s   , /AAmodeeventspurity)dictqueryr   warn_deprecatedcoerce_kw_typeboolsetattrpopdatabaseportr   r
   r   r   makedsnhostr  usernamer&  
setdefault)
r   urloptsoptr  r}  r  makedsn_kwargsr  r  s
   `         r   create_connect_argsz+OracleDialect_cx_oracle.create_connect_args  s   CII4 	2Cd{$$HJMN!
 ##D#t4c488C=1	2 <<xx5|88D4yL--@  "'!2"0,!?$$**$$SXXtF~FC ((C?DK<<#"||D<<#<<DL##/OOJ(@(@A
	 	D&*DED*d3D(D1D(,FGDzr   c                 l    t        d |j                  j                  j                  d      D              S )Nc              3   2   K   | ]  }t        |        y wr   r   r>  s     r   rA  zCOracleDialect_cx_oracle._get_server_version_info.<locals>.<genexpr>]  s     NSVNs   rN  )r	  rK  r/  rT  r   rK  s     r   _get_server_version_infoz0OracleDialect_cx_oracle._get_server_version_info\  s*    NZ%:%:%B%B%H%H%MNNNr   c                    |j                   \  }t        || j                  j                  | j                  j                  f      rdt        |      v ryt        |d      r|j                  dv ryt        j                  dt        |            ryy)Nznot connectedTcode>   	  )  *  ?  \	     z(^(?:DPI-1010|DPI-1080|DPY-1001|DPY-4011)F)
argsr9   r   InterfaceErrorDatabaseErrorrR  r   r  rB  rC  )r   erK  r   errors        r   is_disconnectz%OracleDialect_cx_oracle.is_disconnect_  s|    66

))4::+C+CD
Q'5&!ejj 5
 '
 88?QH r   c                 J    t        j                  dddz        }dd|z  ddz  fS )zcreate a two-phase transaction ID.

        this id will be passed to do_begin_twophase(), do_rollback_twophase(),
        do_commit_twophase().  its format is unspecified.

        r   r     i4  z%032x	   )randomrandint)r   id_s     r   
create_xidz"OracleDialect_cx_oracle.create_xid  s-     nnQS)#w{33r   c                 ^    t        |t              rt        |      }|j                  ||       y r   )r9   r	  listexecutemany)r   r   	statementr   contexts        r   do_executemanyz&OracleDialect_cx_oracle.do_executemany  s&    j%(j)J9j1r   c                 h     |j                   j                  |  ||j                   j                  d<   y )Ncx_oracle_xid)rK  begininfo)r   rK  xids      r   do_begin_twophasez)OracleDialect_cx_oracle.do_begin_twophase  s.    #
##S)69
""?3r   c                 V    |j                   j                         }||j                  d<   y )Ncx_oracle_prepared)rK  preparer  )r   rK  r  rX  s       r   do_prepare_twophasez+OracleDialect_cx_oracle.do_prepare_twophase  s%    &&..006
,-r   c                 :    | j                  |j                         y r   )do_rollbackrK  )r   rK  r  is_preparedrecovers        r   do_rollback_twophasez,OracleDialect_cx_oracle.do_rollback_twophase  s     	../r   c                     |s| j                  |j                         y |rt        d      |j                  d   }|r| j                  |j                         y y )Nz*2pc recovery not implemented for cx_Oracler  )	do_commitrK  NotImplementedErrorr  )r   rK  r  r  r  oci_prepareds         r   do_commit_twophasez*OracleDialect_cx_oracle.do_commit_twophase  sW     NN:001)@  &??+?@Lz445 r   c           
           j                   r& |j                  |D cg c]  \  }}}|
 c}}}  y d |D        } j                  s fd|D        } |j                  di |D ci c]  \  }}||
 c}} y c c}}}w c c}}w )Nc              3   0   K   | ]  \  }}}|r||f  y wr   r0   )r?  r   r   sqltypes       r   rA  z=OracleDialect_cx_oracle.do_set_input_sizes.<locals>.<genexpr>  s%      (C fs   c              3   d   K   | ]'  \  }}j                   j                  |      d    |f ) yw)r   N)r%   _encoder)r?  r   r   r   s      r   rA  z=OracleDialect_cx_oracle.do_set_input_sizes.<locals>.<genexpr>  s6      #V \\**3/2F;s   -0r0   )
positionalsetinputsizesrI  )r   r   list_of_tuplesr  r   r   r  
collections   `       r   do_set_input_sizesz*OracleDialect_cx_oracle.do_set_input_sizes  s    ?? !F  5CDD1S&'&D,:J ..'1

 !F  O:#NKCCK#NO! E  $Os   A;'Bc                     t        d      )Nz5recover two phase query for cx_Oracle not implemented)r  r  s     r   do_recover_twophasez+OracleDialect_cx_oracle.do_recover_twophase  s    !C
 	
r   )TTT2   NNr   )TF)^r2   r3   r4   supports_statement_cacher   execution_ctx_clsr   statement_compilersupports_sane_rowcountsupports_sane_multi_rowcountsupports_unicode_statementsrI  use_setinputsizesdriverr   Numericr6   FloatoracleBINARY_FLOATrW   BINARY_DOUBLEr[   Integerr   rq  r]   Dater_   LargeBinaryr   Boolean_OracleBooleanIntervalr   r   Textr   Stringr   r,  r   CHARrg   rs   rk   r   r   LONGr   RAWr   r   rw   NVARCHARrq   r~   r|   r   r   r*  r  execute_sequence_formatr&  r   deprecated_paramsr%  propertyr;  r.  classmethodr   rG  rY  r`  rJ  rj  rA   rB   rM   rv  rz  r  r  r  r  r  r  r  r  r  r  r  r   r   s   @r   r  r    s   #81!#' "&!F. 	0 	2	
 	. 	} 	{ 	m 	&// 	? 	 	{ 	 	4 	{  	!" 	{#$ 	[

J24-l/H4 #T

 E:
E:N 
 
  
.-^O+Z //Kh#T@DO!F	42
:7
 :?0 :?6 P.
r   r  )H__doc__r4  r   rA   r  rB   r   r  r   r   r   r
   r   r   r   r   enginer   r  sqlr   r   compiler   r  zipr   r  r   r  r6   rS   r  rW   r  r[   r]   r  r_   r  rg   rs   rk   	NVARCHAR2rq   r   rw   r~   r|   r,  r   r  r   r  r   r  r   r   r   r  r   r   r   r  r   r   r   r   r   r  r%   r0   r   r   <module>r     s  B '   	     (   !  '   'BJJ'=>   $Cm$DE X%% &QX%% Qh" "
	,f.A.A 		-v/C/C 	N (--   (--  
!8>> !
 0 0 
!x// !
fll 
X11 
(-- 
!&++ !
	HOO 	(-- H((  foo 
	 	6<< 
/A~ /Ad`
'= `
Ft
m t
n "r   