id:dZddlmZddlZddlZddlZddlZddlmZ ddlm Z ddlm Z ddlm Z d d lm Z d d lmZd d lmZd d lmZd dlmZd dlmZGddejZGddejZGddeZGddee jZGddee jZGddeZGddej Z!Gddej"Z#Gd d!ej$Z%Gd"d#e j&Z'Gd$d%ej(Z)Gd&d'e j*Z+Gd(d)ej,Z-Gd*d+ej.Z/Gd,d-e j0Z1Gd.d/ej2Z3Gd0d1ej4Z5Gd2d3ej6Z7Gd4d5e j8Z9Gd6d7e j:Z;Gd8d9e j<Z=Gd:d;e Z>Gd<d=e Z?Gd>d?ej@ZAGd@dAe ZBeBZCdS)Ba: .. dialect:: oracle+cx_oracle :name: cx-Oracle :dbapi: cx_oracle :connectstring: oracle+cx_oracle://user:pass@host:port/dbname[?key=value&key=value...] :url: https://oracle.github.io/python-cx_Oracle/ DSN vs. Hostname connections ----------------------------- The dialect will connect to a DSN if no database name portion is presented, such as:: engine = create_engine("oracle+cx_oracle://scott:tiger@oracle1120/?encoding=UTF-8&nencoding=UTF-8") Above, ``oracle1120`` is passed to cx_Oracle as an Oracle datasource name. Alternatively, if a database name is present, the ``cx_Oracle.makedsn()`` function is used to create an ad-hoc "datasource" name assuming host and port:: engine = create_engine("oracle+cx_oracle://scott:tiger@hostname:1521/dbname?encoding=UTF-8&nencoding=UTF-8") Above, the DSN would be created as follows:: >>> import cx_Oracle >>> cx_Oracle.makedsn("hostname", 1521, sid="dbname") '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=1521))(CONNECT_DATA=(SID=dbname)))' The ``service_name`` parameter, also consumed by ``cx_Oracle.makedsn()``, may be specified in the URL query string, e.g. ``?service_name=my_service``. 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()`` wihtout 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 } ) 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_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 `_ 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@oracle1120/?encoding=UTF-8&nencoding=UTF-8") For the meaning of the ``encoding`` and ``nencoding`` parameters, please consult `Characters Sets and National Language Support (NLS) `_. .. seealso:: `Characters Sets and National Language Support (NLS) `_ - 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 `_ 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 http://cx-oracle.readthedocs.io/en/latest/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 staements 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)result)compatc eZdZdZdZdZdS)_OracleIntegerctSNintselfdbapis Y/opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/dialects/oracle/cx_oracle.pyget_dbapi_typez_OracleInteger.get_dbapi_typems  c`|j}||jd|jtS)N arraysize outconverter)rvarSTRINGrr)rdialectcursor cx_Oracles r_cx_oracle_varz_OracleInteger._cx_oracle_varrs3M zz  cV-=C   rcfd}|S)Nc0|Sr)r&)r$name default_typesize precisionscaler#rs rhandlerz<_OracleInteger._cx_oracle_outputtypehandler..handlerys&&w77 7r)rr#r.s`` r_cx_oracle_outputtypehandlerz+_OracleInteger._cx_oracle_outputtypehandlerxs) 8 8 8 8 8 8rN)__name__ __module__ __qualname__rr&r0r/rrrrlsA    rrc$eZdZdZdZdZdZdS)_OracleNumericFc|jdkrdS|jr+tjtj|jfd}|StjS)Nrct|ttfr |S|#|rt|S|Sr) isinstancerfloat is_infinite)value processors rprocessz._OracleNumeric.bind_processor..processsQec5\22!$9U+++&5+<+<+>+>& <<' Lr)r- asdecimalr to_decimal_processor_factorydecimalDecimal_effective_decimal_return_scaleto_float)rr#r=r<s @rbind_processorz_OracleNumeric.bind_processorsb :??4 ^ '"?!EI ! ! ! ! !N& &rcdSrr/)rr#coltypes rresult_processorz_OracleNumeric.result_processortrc:jjfd}|S)Ncd}|rV jr8|jkr|}tj}n r tj}n{j} j}nl jr|dkrdSj}nU jr8|jkr|}tj}n4 r tj}n%j} j}n jr|dkrdSj}||d|j|S)Nrrr) r> NATIVE_FLOATr@rAr" _to_decimal is_numberr!r) r$r)r*r+r,r-r type_r%r#is_cx_oracle_6rs rr.z<_OracleNumeric._cx_oracle_outputtypehandler..handlersL& 7>7#y'===!-'. '; ' ) 0'.': ~7%1** $t ) 6>7#y'=== ,'. '; ' ) 0'.': ~7%1** $t ) 6:: *)  r)r_is_cx_oracle_6)rr#r.r%rOs`` @@rr0z+_OracleNumeric._cx_oracle_outputtypehandlersEM  00 0 0 0 0 0 0 0 drN)r1r2r3rMrDrGr0r/rrr5r5sFI'''(77777rr5ceZdZdZdS)_OracleBinaryFloatc|jSr)rKrs rrz!_OracleBinaryFloat.get_dbapi_types !!rNr1r2r3rr/rrrRrRs#"""""rrRceZdZdS)_OracleBINARY_FLOATNr1r2r3r/rrrVrVDrrVceZdZdS)_OracleBINARY_DOUBLENrWr/rrrZrZrXrrZceZdZdZdS) _OracleNUMBERTN)r1r2r3rMr/rrr\r\sIIIrr\ceZdZdZdZdS) _OracleDatecdSrr/rr#s rrDz_OracleDate.bind_processorrHrc d}|S)Nc2||S|Sr)dater;s rr=z-_OracleDate.result_processor..processs zz||# rr/)rr#rFr=s rrGz_OracleDate.result_processors    rN)r1r2r3rDrGr/rrr^r^s2rr^ceZdZdZdS) _OracleCharc|jSr) FIXED_CHARrs rrz_OracleChar.get_dbapi_types rNrTr/rrrfrfs#     rrfceZdZdZdS) _OracleNCharc|jSr) FIXED_NCHARrs rrz_OracleNChar.get_dbapi_type   rNrTr/rrrjrj#!!!!!rrjceZdZdZdS)_OracleUnicodeStringNCHARc|jSr)NCHARrs rrz(_OracleUnicodeStringNCHAR.get_dbapi_type {rNrTr/rrrprp#rrpceZdZdZdS)_OracleUnicodeStringCHARc|jSr LONG_STRINGrs rrz'_OracleUnicodeStringCHAR.get_dbapi_typermrNrTr/rrrvrvrnrrvceZdZdZdS)_OracleUnicodeTextNCLOBc|jSr)NCLOBrs rrz&_OracleUnicodeTextNCLOB.get_dbapi_type rsrNrTr/rrr{r{rtrr{ceZdZdZdS)_OracleUnicodeTextCLOBc|jSrCLOBrs rrz%_OracleUnicodeTextCLOB.get_dbapi_type zrNrTr/rrrr #rrceZdZdZdS) _OracleTextc|jSrrrs rrz_OracleText.get_dbapi_typerrNrTr/rrrrrrrceZdZdZdS) _OracleLongc|jSrrxrs rrz_OracleLong.get_dbapi_typermrNrTr/rrrrrnrrceZdZdS) _OracleStringNrWr/rrrrrXrrceZdZdZdS) _OracleEnumcRtj||fd}|S)Nc|}|Srr/)r;raw_str enum_procs rr=z+_OracleEnum.bind_processor..process$si&&GNr)sqltypesEnumrD)rr#r=rs @rrDz_OracleEnum.bind_processor!s:M00w??      rN)r1r2r3rDr/rrrr s#rrc*eZdZdZdZfdZxZS) _OracleBinaryc|jSr)BLOBrs rrz_OracleBinary.get_dbapi_type,rrcdSrr/r`s rrDz_OracleBinary.bind_processor/rHrch|jsdStt|||Sr)auto_convert_lobssuperrrG)rr#rF __class__s rrGz_OracleBinary.result_processor2s:( 4-->> r)r1r2r3rrDrG __classcell__rs@rrr+sVrrceZdZdZdS)_OracleIntervalc|jSr)INTERVALrs rrz_OracleInterval.get_dbapi_type<s ~rNrTr/rrrr;s#rrceZdZdS) _OracleRawNrWr/rrrr@rXrrceZdZdZdS) _OracleRowidc|jSr)ROWIDrs rrz_OracleRowid.get_dbapi_typeErsrNrTr/rrrrDrtrrceZdZdZdZdS)OracleCompiler_cx_oracleTc ,t|dd}|dus|duri|j|rO|ddrt jd|zd|z}||j|<tj||fi|Stj||fi|S)NquoteTF expandingzyCan't use expanding feature with parameter name %r on Oracle; it requires quoting which is not supported in this context.z"%s") getattrpreparer_bindparam_requires_quotesgetr CompileError_quoted_bind_namesrbindparam_string)rr)kwr quoted_names rrz)OracleCompiler_cx_oracle.bindparam_stringLsgt,, TMME!! 88>>"vvk5)) &')-. !4-K,7D #D )!24KKKK K!24DDDD DrN)r1r2r3_oracle_cx_sql_compilerrr/rrrrIs."EEEEErrc<eZdZdZdZdZdZdZdZdZ dZ dS) OracleExecutionContext_cx_oracleNc|jj}|r2|jD],}|D]\}}||||<||=+dSdSr)compiledr parametersitems)rquoted_bind_namesparamfromnametonames r_setup_quoted_bind_namesz9OracleExecutionContext_cx_oracle._setup_quoted_bind_namescsu M<  ( ( ((9(?(?(A(A(($Hf$)(OE&Mh( ( ( ( (rct|jdkrd|jj}|jjD]:}|jr-|jj|}|j |j }t|dr*| |j |j |j|<n||j j}|j j}|%t#jd|jd|jdt(jrb||j|jfvrRt1j|j j|j j|j |fd|j|<n||j|j|jfvr&|j |d |j|<nt(jrit=|t>j rOt1j|j j|j j|j ||j|<n"|j ||j|<|j||j!d |"||<:dSdS) Nrr&z*Cannot create out parameter for parameter z - its type z is not supported by cx_oracleerrorsc>|Srread)r;r s rzIOracleExecutionContext_cx_oracle._handle_out_parameters..s<<$)JJLL<"<"rr c*|Srrrds rrzIOracleExecutionContext_cx_oracle._handle_out_parameters..s5::<<rr)#lencompiled_parametersrrbindsvalues isoutparam bind_namestype dialect_implr#hasattrr&r$out_parametersrrr InvalidRequestErrorkeyrpy2krr}r to_unicode_processor_factoryencodingencoding_errorsr!rr8rUnicoderr)rr bindparamr) type_impldbtyper%r s @r_handle_out_parametersz7OracleExecutionContext_cx_oracle._handle_out_parametersks t' ( (A - - $ @ !]07799? 2? 2 '>2=3I>D ) ; ;DL I IIy*:;;7P4=4L4L L$+55+D11"+!9!9$,:L!M!M$(L$6 !>"%"9"91: y~~~!O##";&P6%N%O6,, !+ G$(L$9+/<+G!"!"!") 9=  &."."."."9H99D/55$%N%N%O( 9=  &5O5O9H99D/55$[ PZ%x'7.. P!+ G$(L$9+/<+G!"!"!") 9=  &\9H99D/559= 8O8OD/5+D1OA&)--dD99 . -? 2? 2rc i |jjD]I\}}}}||jd|j}|r|j|}| |<J r |jj fd}||j_dSdS)Ncx_oracle_outputtypehandlercX|vr|||||||S||||||Srr/)r$r)r*r+r,r-default_handleroutput_handlerss routput_type_handlerzaOracleExecutionContext_cx_oracle._generate_cursor_outputtype_handler..output_type_handlersY?**0?40lD)U+?lD)Ur) r_result_columns_cached_custom_processorr#_get_cx_oracle_type_handlerdenormalize_name_dbapi_connectionoutputtypehandlerr$) rkeynamer)objectsrNr.denormalized_namerrrs @@r#_generate_cursor_outputtype_handlerzDOracleExecutionContext_cx_oracle._generate_cursor_outputtype_handlers/3}/L = = +WdGU44 -0G  =$(L$A$A'$J$J!5< 12  @"4FO      -@DK ) ) ) @ @rcZt|dr||jSdS)Nr0)rr0r#)rimpls rrzzEOracleExecutionContext_cx_oracle.get_result_proxy..sE    **4+>x!|+LMM   rrc3VK|]#\}}|j|fV$dSr)_dialect _paramval)rkvrs r zDOracleExecutionContext_cx_oracle.get_result_proxy..sP--1 //223------r)rr returningrangerReturningResultProxy_result ResultProxyrrrrrr#rrrGrdict) rreturning_paramsrrbindr)rN impl_type dbapi_typerGs ` rget_result_proxyz1OracleExecutionContext_cx_oracle.get_result_proxys   @4=#: @    s4#67788    (.>?? ?$T**   (4011Q669;;%"&-":"@"@"B"BJD$t222 $ $)$6$6t|$D$D %.%=%= L.&& ,5+E+E L*,,(,73C3C $ 6 6$($7$=!"!"44N400 48<3I3I $ 3D 944N40#*)----- $ 3 9 9 ; ;---))%  r) r1r2r3rrrrrrrrr/rrrr`sN(((C2C2C2J@@@> 333$+++++rrc.eZdZdZfdZdZdZxZS)r zOResult proxy which stuffs the _returning clause + outparams into the fetch.cf||_tt||dSr)_returning_paramsrr __init__)rcontextrrs rrzReturningResultProxy.__init__ s0!1 "D))227;;;;;rc<|jjj}d|DS)Nc>g|]}t|d|jdfS)r)N)r anon_label)rcols rrz.&s8   =@WS&#. 1 14 8   r)rrr )rr s r_cursor_descriptionz(ReturningResultProxy._cursor_description$s0L)3   DM    rcPtjt|jgSr) collectionsdequetuplerrs r _buffer_rowsz!ReturningResultProxy._buffer_rows*s! %(>"?"?!@AAAr)r1r2r3__doc__rrr"rrs@rr r sg<<<<<   BBBBBBBrr c eZdZeZeZdZdZdZ dZ dZ ie j ee jeejeejee jeejee jee jee jeje je ej!e e j"e#e j$e%e j&e'e j(e)e j*e+e j,e-ej.e/ej0e1e j2e3e j4e5ej6e7ej8e9iZ:e;Zj?d ddZ@eAdZBd ZCeDd ZEfd ZFd ZGd ZHdZIdZJeKjLZMdZNdZOdZPdZQdZRe>jSdddZTd dZUdZVdZW d!dZX d!dZYdZZxZ[S)"OracleDialect_cx_oracleT cx_oracleN)z1.3a8The '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`.)threaded2c 4tj|fi|||_||_|||_||_||_||_|jrP|j |_ t|j tj <t|j tj<|j}|i|_d|_n||j|_|jdkr|jdkrt+jd|j|j|j|j|j|j|j|j|jt@tBtDh |_d|_#|jdk|_$|j$rd|j%_&d} | |_'n |j#|_'|jdk|_(dS) Nrrr)z-cx_Oracle version 5.2 and above are supportedc*|Sr)getvaluerds rrz2OracleDialect_cx_oracle.__init__..s5>>+;+;r)r TcL |jddS#t$rYdSwxYwNr)r IndexErrorrds rrz7OracleDialect_cx_oracle.__init__.._returningvals:$$|Aq11%$$$#tt$s  ##)r/))rrrr_cx_oracle_threadedrcoerce_to_unicodecoerce_to_decimal_use_nchar_for_unicodecolspecscopyrprrr{ UnicodeTextrr cx_oracle_ver_parse_cx_oracle_verversionr rDATETIMEr}rLOBrrrlrrh TIMESTAMPrrVrZr_values_are_lists __future__dml_ret_array_valrrP) rrr4r5rrr'kwargsr%rs rrz OracleDialect_cx_oracle.__init__Xs, t..v...".  '/D $!2!2!2  & J M..00DM.GDM(* +2IDM(. /J  *,D '!*D  !%!:!:9;L!M!MD !F**t/AI/M/M-C " %$##$ +D '<;DN&*%76%AD "% 49= $6$$$ &3""%)^"#1T9rcv|jr1|jdkr d|jiStjd|jdiS)N)r/encodingErrorszcx_oracle version z does not support encodingErrors)rr:r warnrs r_cursor_var_unicode_kwargsz2OracleDialect_cx_oracle._cursor_var_unicode_kwargssW   !V++($*>?? ))),  rctjd|}|r.td|dddDSdS)Nz(\d+)\.(\d+)(?:\.(\d+))?c38K|]}|t|VdSrrrxs rrz?OracleDialect_cx_oracle._parse_cx_oracle_ver..s(KKAQ]Q]]]]KKrrr,r r*)rematchr!group)rr<ms rr;z,OracleDialect_cx_oracle._parse_cx_oracle_versN H0' : :  KKAq)9)9KKKKK K9rcddl}|Sr1)r%)clsr%s rrzOracleDialect_cx_oracle.dbapisrctt|||jrd|_||dS)NF)rr% initialize _is_oracle_8supports_unicode_binds_detect_decimal_char)r connectionrs rrTz"OracleDialect_cx_oracle.initializesO %t,,77 CCC   0*/D ' !!*-----rc|5}|t}|dd|i|}|dd\}}}|d|||d|}|tjd|d} dddn #1swxYwY| S) 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)))xidusnxidslotxidsqnz"could not retrieve isolation levelr) r$r!strexecuter.splitfetchoner r) rrXr$outvalrZr\r]r^rowrs rget_isolation_levelz+OracleDialect_cx_oracle.get_isolation_levels4    F ZZ__F NN V$    ((H&.nnS!&<&< #FGV NN1 "gHH   //##C{-8VF?               B sB-CCCct|dr|j}n|}|dkr d|_dSd|_||5}|d|zddddS#1swxYwYdS)NrX AUTOCOMMITTFz$ALTER SESSION SET ISOLATION_LEVEL=%s)rrX autocommitrollbackr$r`)rrXleveldbapi_connectionr$s rset_isolation_levelz+OracleDialect_cx_oracle.set_isolation_levels :| , , *)4  )  L *.  ' ' '*/  '    ! ! !""$$ OEMNNN O O O O O O O O O O O O O O O O O OsA??BBc|dd_jdkr&jjfd_fd_dSdS)NzSselect value from nls_session_parameters where parameter = 'NLS_NUMERIC_CHARACTERS'rr[cL|jdSNr[replace _decimal_char)r;_detect_decimalrs rrz>OracleDialect_cx_oracle._detect_decimal_char..s' d0#6622rcL|jdSrorp)r;rLrs rrz>OracleDialect_cx_oracle._detect_decimal_char..s'[[ d0#66..r)scalarrrrsrL)rrXrsrLs` @@rrWz,OracleDialect_cx_oracle._detect_decimal_chars(.. 9       $ $"2O*K$$$$$D      D    % $rcRd|vr||St|Sro)rLr)rr;s rrsz'OracleDialect_cx_oracle._detect_decimals+ %<<##E** *u:: rc|jtdtdfd}|S)z^establish the default outputtypehandler established at the connection level. T)r>Fc|jkrl|jurcjsdS|dkr,|dvr(|jdj|jS|r|dkr ||||||S ||||||Sjr|jjfvr|j ur||j urstj rCtjjj}|j||j|S|jt"j||jfijSjr~|j j fvrntj rCtjjj}|j||j|S|jj||jfijSjr+|jfvr#|j||jSdSdS)Nr)rir)r rrr)NUMBERrKr5r!r"rsrr4rhrr}rrr rrrr text_typerHrryr LONG_BINARY) r$r)r*r+r,r-r r%r# float_handlernumber_handlers rrz\OracleDialect_cx_oracle._generate_connection_outputtype_handler..output_type_handler5s  000 (>>>04!^^(:(:"::!(%,%<"("2 & 5199)>lD)U)=lD)U )9  $( ! 66 77;#-#J(1H$$$L"::!((%1 &&6:("< * |@00;#-#J(1H$$$L"::!-(%1 &&6:!-("< * |@00zz)$  00r)rr\r0)rrr%r#r|r}s @@@@r'_generate_connection_outputtype_handlerz?OracleDialect_cx_oracle._generate_connection_outputtype_handler%s M &   & &w / / &   & &w / / V V V V V V V V p#"rc:|fd}|S)Nc|_dSr)r)connrs r on_connectz6OracleDialect_cx_oracle.on_connect..on_connects%8D " " "r)r~)rrrs @rrz"OracleDialect_cx_oracle.on_connects6"JJLL 9 9 9 9 9rcXt|j}dD]\}||vrVtjd|ztj||t t |||]|j}|dd}|s|rY|j }|rt|}nd}|r|rtj d|rd|i}|rd|i}j j|j|fi|}n|j}|||d<|j |j|d<|j |j|d <j|d jfd } tj|d | tj|d t tj|d t tj|d| g|fS)N)use_ansirzfcx_oracle dialect option %r should only be passed to create_engine directly, not within the URL string service_nameizI"service_name" option shouldn't be used with a "database" part of the urlsiddsnpassworduserr'ct|tjrK t|}|S#t$r,|}t j|cYSwxYw|Sr)r8r string_typesr ValueErrorupperrr)r;int_valrs rconvert_cx_oracle_constantzOOracleDialect_cx_oracle.create_connect_args..convert_cx_oracle_constantsx%!233 #!%jjG #N "666!KKMME"4:u555556  s.3A$#A$modeeventspurity)rqueryr warn_deprecatedcoerce_kw_typeboolsetattrpopdatabaseportrr rrmakedsnhostrusernamer3 setdefault) rurloptsoptrrrmakedsn_kwargsrrs ` rcreate_connect_argsz+OracleDialect_cx_oracle.create_connect_argssCI5 2 2Cd{{$HJMN#D#t444c488C==111<xx55  | 8D 4yy L -@ 3"'!2 @"0,!?$$*$SXtFF~FFCC(C ?DK < #"|D  < #.s(NNSVVNNNNNNrr[)r!rXr<rarrXs r_get_server_version_infoz0OracleDialect_cx_oracle._get_server_version_infos3NNZ%:%B%H%H%M%MNNNNNNrc|j\}t||jj|jjfrdt |vrdSt |dr |jdvSdS)Nz not connectedTcode)i* i) i? i i\ F)argsr8rInterfaceError DatabaseErrorr_rr)rerXr$errors r is_disconnectz%OracleDialect_cx_oracle.is_disconnectsn6   )4:+CD   Q''4 5& ! ! :!CC C5rz1.2aThe create_xid() method of the cx_Oracle dialect is deprecated and will be removed in a future release. Two-phase transaction support is no longer functional in SQLAlchemy's cx_Oracle dialect as of cx_Oracle 6.0b1, which no longer supports the API that SQLAlchemy relied upon.cHtjdddz}dd|zddzfS)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. rr,i4z%032x )randomrandint)rid_s r create_xidz"OracleDialect_cx_oracle.create_xids. nQS))# w{33rczt|trt|}|||dSr)r8r!list executemany)rr$ statementrrs rdo_executemanyz&OracleDialect_cx_oracle.do_executemanys= j% ( ( *j))J9j11111rc$|jj|dSr)rXbegin)rrXxids rdo_begin_twophasez)OracleDialect_cx_oracle.do_begin_twophases# #S))))rcL|j}||jd<dSNcx_oracle_prepared)rXprepareinfo)rrXrrs rdo_prepare_twophasez+OracleDialect_cx_oracle.do_prepare_twophase s)&..0006 ,---rFc:||jdSr) do_rollbackrX)rrXr is_preparedrecovers rdo_rollback_twophasez,OracleDialect_cx_oracle.do_rollback_twophases! ./////rc|s||jdS|jd}|r||jdSdSr) do_commitrXr)rrXrrr oci_prepareds rdo_commit_twophasez*OracleDialect_cx_oracle.do_commit_twophasesa 6 NN:0 1 1 1 1 1%?+?@L 6z455555 6 6rc<|jdddSr)rrrs rdo_recover_twophasez+OracleDialect_cx_oracle.do_recover_twophases!0$77777r)TTTr(NNr)TF)\r1r2r3rexecution_ctx_clsrstatement_compilersupports_sane_rowcountsupports_sane_multi_rowcountsupports_unicode_statementsrVdriverrNumericr5Floatoracle BINARY_FLOATrV BINARY_DOUBLErZIntegerrryr\Dater^ LargeBinaryrBoolean_OracleBooleanIntervalrrTextrStringrr9rCHARrfrrrjrrLONGrRAWrrrvNVARCHARrpr}r{rrr7rexecute_sequence_formatr3r deprecated_paramsrpropertyrHr; classmethodrrTrerlrWrsr@rArLr~rrrr deprecatedrrrrrrrrrs@rr%r%.s81!#' "&! F. 0 2  .   }   { m &/ ?   {  4  {  !"  {#$  [ J24 - l/H4#T    E:E:E:  E:N  X [ .....---^ O O O, /Kh#h#h#T@@@DOOO&T_  ? 4 4 42222 ***777 :?0000 :?66668888888rr%)Dr#rArrr@rrMrrrrrr r r rr enginerr rrrrr5rRrrVrrZr\rr^rrfrrrj NVARCHAR2rprrvr}r{r9rrrrrrrrrrrrrrrrrrrFullyBufferedResultProxyr r%r#r/rrrsPPd '&&&&&  ((((((!!!!!!''''''X%&QQQQQX%QQQh""""""""      ,f.A        -v/C   N     (-         (-   !!!!!8>!!!  0 !!!!!x/!!! fl X1 (- !!!!!&+!!!      HO   (-     H(    fo         6< EEEEE~EEE.yyyyy'=yyyxBBBBB7;BBB$q8q8q8q8q8mq8q8q8h "r