U a@sdZddlZddlmZddlmZddlmZddlmZ dd lm Z Gd d d e Z Gd d d e e j ZGddde e jZGdddeZGdddeZeZdS)aO .. dialect:: firebird+kinterbasdb :name: kinterbasdb :dbapi: kinterbasdb :connectstring: firebird+kinterbasdb://user:password@host:port/path/to/db[?key=value&key=value...] :url: https://firebirdsql.org/index.php?op=devel&sub=python Arguments ---------- The Kinterbasdb backend accepts the ``enable_rowcount`` and ``retaining`` arguments accepted by the :mod:`sqlalchemy.dialects.firebird.fdb` dialect. In addition, it also accepts the following: * ``type_conv`` - select the kind of mapping done on the types: by default SQLAlchemy uses 200 with Unicode, datetime and decimal support. See the linked documents below for further information. * ``concurrency_level`` - set the backend policy with regards to threading issues: by default SQLAlchemy uses policy 1. See the linked documents below for further information. .. seealso:: https://sourceforge.net/projects/kinterbasdb https://kinterbasdb.sourceforge.net/dist_docs/usage.html#adv_param_conv_dynamic_type_translation https://kinterbasdb.sourceforge.net/dist_docs/usage.html#special_issue_concurrency N)match) FBDialect)FBExecutionContext)types)utilc@seZdZddZdS)_kinterbasdb_numericcCs dd}|S)NcSst|tjrt|S|SdSN) isinstancedecimalDecimalstr)valueriC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\dialects\firebird\kinterbasdb.pyprocess3s z4_kinterbasdb_numeric.bind_processor..processr)selfdialectrrrrbind_processor2sz#_kinterbasdb_numeric.bind_processorN)__name__ __module__ __qualname__rrrrrr 1sr c@s eZdZdS)_FBNumeric_kinterbasdbNrrrrrrrr<src@s eZdZdS)_FBFloat_kinterbasdbNrrrrrr@src@seZdZeddZdS)FBExecutionContext_kinterbasdbcCs"|jd|jjr|jjSdSdS)Nenable_rowcount)Zexecution_optionsgetrrcursorrowcount)rrrrr!Es z'FBExecutionContext_kinterbasdb.rowcountN)rrrpropertyr!rrrrrDsrcseZdZdZdZdZdZeZdZ e e j ejeejeiZ dfdd Zedd Zdd d Zd dZddZddZddZddZddZZS)FBDialect_kinterbasdb kinterbasdbTFrc s8tt|jf|||_||_||_||_|r4d|_dS)NT)superr#__init__r type_convconcurrency_level retainingsupports_sane_rowcount)rr(r)rr*kwargs __class__rrr'`szFBDialect_kinterbasdb.__init__cCstdS)Nr$) __import__)clsrrrdbapipszFBDialect_kinterbasdb.dbapiNcCs|||p gdSr )execute)rr Z statement parameterscontextrrr do_executetsz FBDialect_kinterbasdb.do_executecCs||jdSr )rollbackr*rZdbapi_connectionrrr do_rollbackysz!FBDialect_kinterbasdb.do_rollbackcCs||jdSr )commitr*r7rrr do_commit|szFBDialect_kinterbasdb.do_commitcCs|jdd}|dr4d|d|df|d<|d=||jt|dt|d|j}|d|j }|j dk rt |j dd}|dkrt |j d d }|s|j j ||d g|fS) Nuser)usernameportz%s/%shostr(r) initialized _initializedF)r(r)) Ztranslate_connect_argsrupdatequeryrZcoerce_kw_typeintpopr(r)r1getattrinit)rurloptsr(r)r?rrrcreate_connect_argss*    z)FBDialect_kinterbasdb.create_connect_argscCs|j}|j}||S)zGet the version of the Firebird server used by a connection. Returns a tuple of (`major`, `minor`, `build`), three integers representing the version of the attached server. ) connectionZserver_version_parse_version_info)rrJZfbconnversionrrr_get_server_version_infos z.FBDialect_kinterbasdb._get_server_version_infocCsptd|}|std||ddkrJtdd|dddDd gStd d|d d d DdgSdS)Nz3\w+-V(\d+)\.(\d+)\.(\d+)\.(\d+)( \w+ (\d+)\.(\d+))?z,Could not determine version from string '%s'cSsg|] }t|qSrrC.0xrrr sz=FBDialect_kinterbasdb._parse_version_info..ZfirebirdcSsg|] }t|qSrrOrPrrrrSsrrZ interbase)rAssertionErrorgrouptuple)rrLmrrrrKs"z)FBDialect_kinterbasdb._parse_version_infocCsNt||jj|jjfrFt|}d|kpDd|kpDd|kpDd|kpDd|kSdSdS)Nz$Error writing data to the connectionz*Unable to complete network request to hostzInvalid connection statezInvalid cursor statezconnection shutdownF)r r1ZOperationalErrorZProgrammingErrorr)rerJr msgrrr is_disconnectsz#FBDialect_kinterbasdb.is_disconnect)r%rTF)N)rrrZdriverZsupports_statement_cacher+Zsupports_sane_multi_rowcountrZexecution_ctx_clsZsupports_native_decimalrZ update_copyrZcolspecssqltypesNumericrFloatrr' classmethodr1r5r8r:rIrMrKr^ __classcell__rrr-rr#Os8   r#)__doc__r rerbaserrrr_robjectr r`rrarrr#rrrrrs        {