U a"@s\dZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd l m Z dd l mZdd l mZddlmZddlmZddlmZddlmZdd lmZddlmZGdddeZGddde ZGdddeZGdddeZGddde ZGdddeZGd d!d!e ZGd"d#d#eZ e Z!dS)$a3 .. dialect:: postgresql+pygresql :name: pygresql :dbapi: pgdb :connectstring: postgresql+pygresql://user:password@host:port/dbname[?key=value&key=value...] :url: https://www.pygresql.org/ .. note:: The pygresql dialect is **not tested as part of SQLAlchemy's continuous integration** and may have unresolved issues. The recommended PostgreSQL dialect is psycopg2. .. deprecated:: 1.4 The pygresql DBAPI is deprecated and will be removed in a future version. Please use one of the supported DBAPIs to connect to PostgreSQL. N)_DECIMAL_TYPES) _FLOAT_TYPES) _INT_TYPES) PGCompiler) PGDialect)PGIdentifierPreparer)UUID)HSTORE)JSON)JSONB)exc) processors)util)Null)Numericc@seZdZddZddZdS) _PGNumericcCsdSN)selfdialectrrhC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\dialects\postgresql\pygresql.pybind_processor0sz_PGNumeric.bind_processorcCst|ts|j}|jrR|tkr.ttj|j S|t ks>|t krBdSt d|n0|tkr^dS|t ksn|t krttjSt d|dS)NzUnknown PG numeric type: %d) isinstanceintoidZ asdecimalrrZto_decimal_processor_factorydecimalDecimalZ_effective_decimal_return_scalerrrZInvalidRequestErrorZto_floatrrcoltyperrrresult_processor3s( z_PGNumeric.result_processorN)__name__ __module__ __qualname__rr!rrrrr/srcs(eZdZfddZfddZZS) _PGHStorecs.|jstt||S|jjfdd}|S)Ncst|tr|S|Sr)rdictvaluehstorerrprocessTs z)_PGHStore.bind_processor..process)has_native_hstoresuperr%rdbapiZHstorerrr+ __class__r)rrOs  z_PGHStore.bind_processorcs|jstt|||SdSr)r,r-r%r!rr0rrr![sz_PGHStore.result_processorr"r#r$rr! __classcell__rrr0rr%Ns r%cs(eZdZfddZfddZZS)_PGJSONcs0|jstt|S|jjfdd}|S)NcsN|jkrd}nt|ts(|dkr,jr,dS|dksBt|ttfrJ|S|SrNULLrrZ none_as_nullr&listr'jsonrrrr+fs  z'_PGJSON.bind_processor..process)has_native_jsonr-r4rr.Jsonr/r0r8rras  z_PGJSON.bind_processorcs|jstt|||SdSr)r:r-r4r!rr0rrr!ssz_PGJSON.result_processorr2rrr0rr4`s r4cs(eZdZfddZfddZZS)_PGJSONBcs0|jstt|S|jjfdd}|S)NcsN|jkrd}nt|ts(|dkr,jr,dS|dksBt|ttfrJ|S|Srr5r'r8rrr+~s  z(_PGJSONB.bind_processor..process)r:r-r<rr.r;r/r0r8rrys  z_PGJSONB.bind_processorcs|jstt|||SdSr)r:r-r<r!rr0rrr!sz_PGJSONB.result_processorr2rrr0rr<xs r<cs(eZdZfddZfddZZS)_PGUUIDcs.|jstt||S|jjfdd}|S)NcsP|dkr dSt|ttfr8t|dkr0|dS|St|trL|dS|S)N)bytes)r)rstrr?lenrr'uuidrrr+s    z'_PGUUID.bind_processor..process)has_native_uuidr-r=rr.ZUuidr/r0rBrrs  z_PGUUID.bind_processorcs.|jstt|||S|js*dd}|SdS)NcSs|dk rt|SdSr)r@r'rrrr+sz)_PGUUID.result_processor..process)rDr-r=r!Zas_uuid)rrr r+r0rrr!s z_PGUUID.result_processorr2rrr0rr=s r=c@seZdZddZddZdS) _PGCompilercKs$|j|jf|d|j|jf|S)Nz %% )r+leftright)rbinaryoperatorkwrrrvisit_mod_binarys z_PGCompiler.visit_mod_binarycCs |ddSN%z%%)replace)rtextrrrpost_process_textsz_PGCompiler.post_process_textN)r"r#r$rKrPrrrrrEsrEc@seZdZddZdS)_PGIdentifierPreparercCs||j|j}|ddSrL)rNZ escape_quoteZescape_to_quote)rr(rrr_escape_identifiersz(_PGIdentifierPreparer._escape_identifierN)r"r#r$rRrrrrrQsrQcsneZdZdZdZeZeZe ddZ e e jeeeeeeeeeeeeiZfddZddZd d ZZS) PGDialect_pygresqlZpygresqlTcCsddl}tjddd|S)NrzThe pygresql DBAPI is deprecated and will be removed in a future version. Please use one of the supported DBAPIs to connect to PostgreSQL.z1.4)version)pgdbrZwarn_deprecated)clsrUrrrr.s zPGDialect_pygresql.dbapic stt|jf|z4|jj}td|}t|dt|df}Wnt t t fk rdd}YnX||_ |dkrd}}}|dkrt dnd|_d|_d}}}||_||_||_dS) Nz (\d+)\.(\d+)r)rr)rFzAPyGreSQL is only fully supported by SQLAlchemy since version 5.0.T)r-rS__init__r.rTrematchrgroupAttributeError ValueError TypeErrorZ dbapi_versionrwarnZsupports_unicode_statementsZsupports_unicode_bindsr,r:rD)rkwargsrTmr,r:rDr0rrrYs(     zPGDialect_pygresql.__init__cCsR|jdd}d|kr>d|ddddd |df|d<||jg|fS) Nuser)usernameportz%s:%shost:rr)Ztranslate_connect_argsgetrsplitpopupdatequery)rurloptsrrrcreate_connect_argss   z&PGDialect_pygresql.create_connect_argscCsjt||jjrf|sdSz |j}Wntk r4Yn X|s>dSz|jWStk rd|jdkYSXdS)NF)rr.Error connectionr]closedZ_cnx)rerrcursorrrr is_disconnects z PGDialect_pygresql.is_disconnect)r"r#r$ZdriverZsupports_statement_cacherEZstatement_compilerrQpreparer classmethodr.rZ update_copyrZcolspecsrrr r%r;r4r r r<r r=rYrprvr3rrr0rrSs2   rS)"__doc__rrZbaserrrrrrr r*r r9r r rgrrrZ sql.elementsrtypesr;rrr%r4r<r=rErQrSrrrrrs6                 U