U kf( @sdZddlmZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#ddl"m#Z#ddl"m$Z$ddl"m$Z$ddlm%Z%dd l&m'Z'dd!l(m)Z)dd"l(m*Z*dd#l(m+Z+dd$l(m,Z,erd%d&l-m.Z.d%d'l-m/Z/d%d(l0m1Z1d%d)l2m3Z3dd*lm4Z4dd+lm5Z5dd,l6m7Z7dd-l8m9Z9dd.l"m:Z:dd/l"m;Z;dd0l"mZ>dd3l"m?Z?dd4l@mAZAdd5l@mBZBdd6lCmDZDdd7lCmEZEdd8lCmFZFddlCmZGdd9lHmIZIdd:lJmKZKdd;lJmLZLeeeMeeMeffZNedZOGd?d@d@eZPGdAdBdBeZQGdCdDdDe+ZRGdEdFdFe+ZSGdGdHdHe+ZTeeMefZUeeMefZVeeUZWeeWeUfZXeeeeUfZYeeeeeWfZZeeZeYfZ[eeeMdFee\ee\ee\ee\ee]fZ^eYZ_eZZ`e[ZaeedIfZbeeeMeeMfZce%eMefZde)dJZeeeeMedKfZfe)dLZgGdMdNdNe,dOdPZhe%eMefZieeheeMeffZjGdQdRdRe,ZkGdSdTdTe,ZlGdUdVdVe,ZmGdWdXdXe,ZnGdYdZdZenZoGd[d\d\enZpGd]d^d^enZqGd_d`d`enZrGdadbdbe,ZsGdcdddde,ZtGdedfdfeZueee\eMfdgfZveeeMeMfZwGdhdidieZxGdjdkdkZyGdldmdmZzGdndodoeZ{e{Z|GdpdqdqZ}GdrdsdsZ~dtS)uz1Define core interfaces used by the engine system.) annotations)Enum) ModuleType)Any) Awaitable)Callable)ClassVar) Collection)Dict)Iterable)Iterator)List)Mapping)MutableMapping)Optional)Sequence)Set)Tuple)Type) TYPE_CHECKING)TypeVar)Union)util) EventTarget)Pool)PoolProxiedConnection)Compiled) TypeCompiler) immutabledict) await_only)Literal) NotRequired)Protocol) TypedDict) Connection)Engine) CursorResult)URL)_ListenerFnType) dispatcher)StatementError) Executable)_InsertManyValuesBatch) DDLCompiler)IdentifierPreparer)InsertmanyvaluesSentinelOpts)Linting) SQLCompiler) BindParameter) ClauseElement)Column)DefaultGenerator) SchemaItem)Integer) _TypeMemoDict) TypeEngine_Tr)boundc@s eZdZdZdZdZdZdZdS) CacheStatsrr%rN)__name__ __module__ __qualname__ CACHE_HIT CACHE_MISSCACHING_DISABLED NO_CACHE_KEYNO_DIALECT_SUPPORTrIrIL/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/engine/interfaces.pyr>Os r>c@seZdZdZdZdZdZdS) ExecuteStylezVindicates the :term:`DBAPI` cursor method that will be used to invoke a statement.rr%rN)rArBrC__doc__ZEXECUTEZ EXECUTEMANYZINSERTMANYVALUESrIrIrIrJrKWs rKc@sReZdZUdZddddZddddZddd d Zddd d Zd ed<dS)DBAPIConnectionzprotocol representing a :pep:`249` database connection. .. versionadded:: 2.0 .. seealso:: `Connection Objects `_ - in :pep:`249` NonereturncCsdSNrIselfrIrIrJcloseyzDBAPIConnection.closecCsdSrQrIrRrIrIrJcommit{rUzDBAPIConnection.commit DBAPICursorcCsdSrQrIrRrIrIrJcursor}rUzDBAPIConnection.cursorcCsdSrQrIrRrIrIrJrollbackrUzDBAPIConnection.rollbackboolZ autocommitN) rArBrCrLrTrVrXrY__annotations__rIrIrIrJrMms  rMc@seZdZdZdS) DBAPITypezprotocol representing a :pep:`249` database type. .. versionadded:: 2.0 .. seealso:: `Type Objects `_ - in :pep:`249` N)rArBrCrLrIrIrIrJr\sr\c@seZdZUdZeddddZeddddZded <ded <d dd d Zd1ddddddZ ddddddZ ddddZ d2dddddZ dddd Z dd d!d"d#Zddd d$d%d&Zd3d'ddd(d)d*Zd+dd,d-Zd'dd.d/d0ZdS)4rWzprotocol representing a :pep:`249` database cursor. .. versionadded:: 2.0 .. seealso:: `Cursor Objects `_ - in :pep:`249` _DBAPICursorDescriptionrOcCsdS)zThe description attribute of the Cursor. .. seealso:: `cursor.description `_ - in :pep:`249` NrIrRrIrIrJ descriptions zDBAPICursor.descriptionintcCsdSrQrIrRrIrIrJrowcountszDBAPICursor.rowcountZ arraysizeZ lastrowidrNcCsdSrQrIrRrIrIrJrTrUzDBAPICursor.closeNr#Optional[_DBAPISingleExecuteParams]) operation parametersrPcCsdSrQrIrSrbrcrIrIrJexecuteszDBAPICursor.execute_DBAPIMultiExecuteParamscCsdSrQrIrdrIrIrJ executemanyszDBAPICursor.executemanyz Optional[Any]cCsdSrQrIrRrIrIrJfetchonerUzDBAPICursor.fetchone. Sequence[Any])sizerPcCsdSrQrI)rSrjrIrIrJ fetchmanyrUzDBAPICursor.fetchmanycCsdSrQrIrRrIrIrJfetchallrUzDBAPICursor.fetchall)sizesrPcCsdSrQrI)rSrmrIrIrJ setinputsizesrUzDBAPICursor.setinputsizes)rjcolumnrPcCsdSrQrI)rSrjrorIrIrJ setoutputsizerUzDBAPICursor.setoutputsizestr)procnamercrPcCsdSrQrI)rSrrrcrIrIrJcallprocszDBAPICursor.callproczOptional[bool]cCsdSrQrIrRrIrIrJnextsetrUzDBAPICursor.nextset)keyrPcCsdSrQrI)rSrurIrIrJ __getattr__rUzDBAPICursor.__getattr__)N).).)rArBrCrLpropertyr^r`r[rTrergrhrkrlrnrprsrtrvrIrIrIrJrWs(  rWr)ZqmarknumericnamedformatZpyformatZnumeric_dollarTypeEngine[Any])Z SERIALIZABLEzREPEATABLE READzREAD COMMITTEDzREAD UNCOMMITTEDZ AUTOCOMMITc@s^eZdZUded<ded<ded<ded<ded <d ed <d ed <d ed <ded<ded<dS)_CoreKnownExecutionOptionszOptional[CompiledCacheType]Zcompiled_cacherqZ logging_tokenIsolationLevelZisolation_levelrZ no_parametersZstream_resultsr_Zmax_row_bufferZ yield_perinsertmanyvalues_page_sizez Optional[SchemaTranslateMapType]Zschema_translate_mapZpreserve_rowcountN)rArBrCr[rIrIrIrJr|s r|F)totalc@sjeZdZUdZded<ded<ded<ded<ded<ded <ded <ded <ded <d ed<ded<dS)ReflectedIdentitya&represent the reflected IDENTITY structure of a column, corresponding to the :class:`_schema.Identity` construct. The :class:`.ReflectedIdentity` structure is part of the :class:`.ReflectedColumn` structure, which is returned by the :meth:`.Inspector.get_columns` method. rZalwaysZon_nullr_start incrementZminvalueZmaxvalueZ nominvalueZ nomaxvaluecycle Optional[int]cacheorderNrArBrCrLr[rIrIrIrJrs  rc@s"eZdZUdZded<ded<dS)ReflectedComputeda%Represent the reflected elements of a computed column, corresponding to the :class:`_schema.Computed` construct. The :class:`.ReflectedComputed` structure is part of the :class:`.ReflectedColumn` structure, which is returned by the :meth:`.Inspector.get_columns` method. rqsqltextNotRequired[bool]Z persistedNrrIrIrIrJrHs  rc@sZeZdZUdZded<ded<ded<ded <d ed <d ed <ded<ded<ded<dS)ReflectedColumnzDictionary representing the reflected elements corresponding to a :class:`_schema.Column` object. The :class:`.ReflectedColumn` structure is returned by the :class:`.Inspector.get_columns` method. rqnamer{typerZZnullable Optional[str]defaultrZ autoincrementNotRequired[Optional[str]]commentzNotRequired[ReflectedComputed]ZcomputedzNotRequired[ReflectedIdentity]identityNotRequired[Dict[str, Any]]dialect_optionsNrrIrIrIrJrZs  rc@s"eZdZUdZded<ded<dS)ReflectedConstraintzDictionary representing the reflected elements corresponding to :class:`.Constraint` A base class for all constraints rrrrNrrIrIrIrJrs rc@s"eZdZUdZded<ded<dS)ReflectedCheckConstraintzDictionary representing the reflected elements corresponding to :class:`.CheckConstraint`. The :class:`.ReflectedCheckConstraint` structure is returned by the :meth:`.Inspector.get_check_constraints` method. rqrrrNrrIrIrIrJrs rc@s*eZdZUdZded<ded<ded<dS) ReflectedUniqueConstraintzDictionary representing the reflected elements corresponding to :class:`.UniqueConstraint`. The :class:`.ReflectedUniqueConstraint` structure is returned by the :meth:`.Inspector.get_unique_constraints` method. List[str] column_namesrZduplicates_indexrrNrrIrIrIrJrs rc@s"eZdZUdZded<ded<dS)ReflectedPrimaryKeyConstraintzDictionary representing the reflected elements corresponding to :class:`.PrimaryKeyConstraint`. The :class:`.ReflectedPrimaryKeyConstraint` structure is returned by the :meth:`.Inspector.get_pk_constraint` method. rconstrained_columnsrrNrrIrIrIrJrs rc@s:eZdZUdZded<ded<ded<ded<d ed <d S) ReflectedForeignKeyConstraintzDictionary representing the reflected elements corresponding to :class:`.ForeignKeyConstraint`. The :class:`.ReflectedForeignKeyConstraint` structure is returned by the :meth:`.Inspector.get_foreign_keys` method. rrrZreferred_schemarqZreferred_tableZreferred_columnsroptionsNrrIrIrIrJrs rc@sReZdZUdZded<ded<ded<ded <d ed <ded <d ed<ded<dS)ReflectedIndexzDictionary representing the reflected elements corresponding to :class:`.Index`. The :class:`.ReflectedIndex` structure is returned by the :meth:`.Inspector.get_indexes` method. rrzList[Optional[str]]rzNotRequired[List[str]]Z expressionsrZuniquerZduplicates_constraintZinclude_columnsz"NotRequired[Dict[str, Tuple[str]]]Zcolumn_sortingrrNrrIrIrIrJrs  rc@seZdZUdZded<dS)ReflectedTableCommentzDictionary representing the reflected comment corresponding to the :attr:`_schema.Table.comment` attribute. The :class:`.ReflectedTableComment` structure is returned by the :meth:`.Inspector.get_table_comment` method. rtextNrrIrIrIrJr&s rc@seZdZdZdZdZdZdS) BindTypingzDefine different methods of passing typing information for bound parameters in a statement to the database driver. .. versionadded:: 2.0 r%rr?N)rArBrCrLNONEZ SETINPUTSIZESZ RENDER_CASTSrIrIrIrJr3s r.c@s eZdZUdZejZejZejZejZej Z de d<de d<de d<de d<de d <e j d d d d Z de d<de d<de d<de d<de d<de d<de d<de d<de d<de d <d!e d"<d#e d$<d%e d&<d%e d'<d(e d)<d*e d+<de d,<d-e d.<de d/<de d0<de d1<de d2<de d3<de d4<de d5<d6Zde d7<de d8<de d9<de d:<de d;<de d<<de d=<de d><d?e d@<d-e dA<d-e dB<de dC<de dD<de dE<de dF<de dG<de dH<de dI<de dJ<de dK<dLe dM<de dN<de dO<d-e dP<de dQ<de dR<de dS<de dT<de dU<dVZdWe dX<dYZdZe d[<e jZd\e d]<de d^<de d_<de d`<daZdbZde dc<de dd<ejZde de<de df<dge dh<die dj<dke dl<dke dm<de dn<de do<de dp<de dq<dre ds<dtd dudvZdwdxdydzd{Zed d d|d}Zd~d~dddZdddddZer6dddddZdYddd#dddddZ dVdVddd#ddddddZ!dZddd#dddddZ"dVdVddd#ddddddZ#d[ddd#dddddZ$dVdVddd#ddddddZ%d\dd#dddddZ&d]dd#dddddZ'd^dd#dddddZ(d_dd#dddddZ)d`dd#dddddZ*dadd#dddddZ+ddddddZ,dbddd#dddddZ-dcddd#dddddZ.dVdVddd#ddddddZ/ddddd#dddddZ0dVdVddd#ddddddZ1deddd#ddddd„Z2dVdVddd#ddddddńZ3dfddd#dddddȄZ4dVdVddd#dddddd˄Z5dgddd#ddddd΄Z6dVdVddd#ddddddфZ7dddҜddԄZ8dddҜddքZ9dhddd#ddddd؄Z:didddd#dddٜddۄZ;djddd#dddܜddބZdddddZ?dddddZ@dddddZAdddddZBdddddZCdddddZDdddddZEdddddZFdddddddZGdd ddZHddddddZIddddddZJddddddZKddddddZLddddd d ZMdkdddddd d d ZNdldddddd ddZOdddddZPddddddddddZQdmddddddddZRdnddddddddZSdoddddd d!d"ZTd#d$d%dd&d'd(ZUdddd)d*d+ZVdwd,dyd-d.ZWd,d d/d0ZXdddd1d2ZYdd3dd4d5d6ZZdd3dd7d8Z[dd3d9d:d;Z\dd<d9d=d>Z]dd3dd?d@dAZ^edwdBdydCdDZ_edwdBdydEdFZ`edd dGdHZaedIddJdKdLZbddddMdNZcdIdOddPdQdRZdddOddSdTdUZedwdVdydWdXZfdVS(pDialectaeDefine the behavior of a specific database and DB-API combination. Any aspect of metadata definition, SQL query generation, execution, result-set handling, or anything else which varies between databases is defined under the general category of the Dialect. The Dialect acts as a factory for other database-specific object implementations including ExecutionContext, Compiled, DefaultGenerator, and TypeEngine. .. note:: Third party dialects should not subclass :class:`.Dialect` directly. Instead, subclass :class:`.default.DefaultDialect` or descendant class. zdispatcher[Dialect]dispatchrqrZdriverZdialect_descriptionzOptional[ModuleType]ZdbapirrOcCs tdS)zsame as .dbapi, but is never None; will raise an error if no DBAPI was set up. .. versionadded:: 2.0 NNotImplementedErrorrRrIrIrJ loaded_dbapiszDialect.loaded_dbapirZ positionalZ paramstyler2Zcompiler_lintingzType[SQLCompiler]Zstatement_compilerzType[DDLCompiler]Z ddl_compilerzClassVar[Type[TypeCompiler]]Ztype_compiler_clsrZtype_compiler_instancerZ type_compilerzType[IdentifierPreparer]preparerr0Zidentifier_preparerzOptional[Tuple[Any, ...]]Zserver_version_inforZdefault_schema_namezOptional[IsolationLevel]Zdefault_isolation_levelZ_on_connect_isolation_levelzType[ExecutionContext]Zexecution_ctx_clsz4Union[Type[Tuple[Any, ...]], Type[Tuple[List[Any]]]]Zexecute_sequence_formatZsupports_alterr_Zmax_identifier_lengthZsupports_server_side_cursorsZserver_side_cursorsZsupports_sane_rowcountZsupports_sane_multi_rowcountZsupports_empty_insertZsupports_default_valuesZsupports_default_metavalueDEFAULTdefault_metavalue_tokenZsupports_multivalues_insertZinsert_executemany_returningZ4insert_executemany_returning_sort_by_parameter_orderZupdate_executemany_returningZdelete_executemany_returningZuse_insertmanyvaluesZ!use_insertmanyvalues_wo_returningr1Z"insertmanyvalues_implicit_sentinelrZinsertmanyvalues_max_parametersZ"preexecute_autoincrement_sequencesZinsert_returningZupdate_returningZupdate_returning_multifromZdelete_returningZdelete_returning_multifromZfavor_returning_over_lastrowidZsupports_identity_columnsZcte_follows_insertzIterable[Tuple[TableKey, List[ReflectedForeignKeyConstraint]]]cKs tdS)aReturn information about foreign_keys in all tables in the given ``schema``. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_multi_foreign_keys`. .. note:: The :class:`_engine.DefaultDialect` provides a default implementation that will call the single table method for each object returned by :meth:`Dialect.get_table_names`, :meth:`Dialect.get_view_names` or :meth:`Dialect.get_materialized_view_names` depending on the provided ``kind``. Dialects that want to support a faster implementation should implement this method. .. versionadded:: 2.0 NrrrIrIrJget_multi_foreign_keysszDialect.get_multi_foreign_keysr)rrrrPcKs tdS)zReturn a list of table names for ``schema``. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_table_names`. NrrSrrrrIrIrJget_table_namess zDialect.get_table_namescKs tdS)zReturn a list of temporary table names on the given connection, if supported by the underlying backend. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_temp_table_names`. NrrrIrIrJget_temp_table_namess zDialect.get_temp_table_namescKs tdS)aReturn a list of all non-materialized view names available in the database. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_view_names`. :param schema: schema name to query, if not the default schema. NrrrIrIrJget_view_namess zDialect.get_view_namescKs tdS)aFReturn a list of all materialized view names available in the database. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_materialized_view_names`. :param schema: schema name to query, if not the default schema. .. versionadded:: 2.0 NrrrIrIrJget_materialized_view_namessz#Dialect.get_materialized_view_namescKs tdS)a*Return a list of all sequence names available in the database. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_sequence_names`. :param schema: schema name to query, if not the default schema. .. versionadded:: 1.4 NrrrIrIrJget_sequence_namess zDialect.get_sequence_namescKs tdS)zReturn a list of temporary view names on the given connection, if supported by the underlying backend. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_temp_view_names`. NrrrIrIrJget_temp_view_namess zDialect.get_temp_view_names)rrrPcKs tdS)zReturn a list of all schema names available in the database. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_schema_names`. Nr)rSrrrIrIrJget_schema_namesszDialect.get_schema_names)r view_namerrrPcKs tdS)aGReturn plain or materialized view definition. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_view_definition`. Given a :class:`_engine.Connection`, a string ``view_name``, and an optional string ``schema``, return the view definition. Nr)rSrrrrrIrIrJget_view_definitionszDialect.get_view_definitionzList[ReflectedIndex]cKs tdS)aReturn information about indexes in ``table_name``. Given a :class:`_engine.Connection`, a string ``table_name`` and an optional string ``schema``, return index information as a list of dictionaries corresponding to the :class:`.ReflectedIndex` dictionary. This is an internal dialect method. Applications should use :meth:`.Inspector.get_indexes`. NrrrIrIrJ get_indexesszDialect.get_indexesz/Iterable[Tuple[TableKey, List[ReflectedIndex]]]cKs tdS)aReturn information about indexes in in all tables in the given ``schema``. This is an internal dialect method. Applications should use :meth:`.Inspector.get_multi_indexes`. .. note:: The :class:`_engine.DefaultDialect` provides a default implementation that will call the single table method for each object returned by :meth:`Dialect.get_table_names`, :meth:`Dialect.get_view_names` or :meth:`Dialect.get_materialized_view_names` depending on the provided ``kind``. Dialects that want to support a faster implementation should implement this method. .. versionadded:: 2.0 NrrrIrIrJget_multi_indexes#szDialect.get_multi_indexeszList[ReflectedUniqueConstraint]cKs tdS)aReturn information about unique constraints in ``table_name``. Given a string ``table_name`` and an optional string ``schema``, return unique constraint information as a list of dicts corresponding to the :class:`.ReflectedUniqueConstraint` dictionary. This is an internal dialect method. Applications should use :meth:`.Inspector.get_unique_constraints`. NrrrIrIrJget_unique_constraints?szDialect.get_unique_constraintsz:Iterable[Tuple[TableKey, List[ReflectedUniqueConstraint]]]cKs tdS)aReturn information about unique constraints in all tables in the given ``schema``. This is an internal dialect method. Applications should use :meth:`.Inspector.get_multi_unique_constraints`. .. note:: The :class:`_engine.DefaultDialect` provides a default implementation that will call the single table method for each object returned by :meth:`Dialect.get_table_names`, :meth:`Dialect.get_view_names` or :meth:`Dialect.get_materialized_view_names` depending on the provided ``kind``. Dialects that want to support a faster implementation should implement this method. .. versionadded:: 2.0 NrrrIrIrJget_multi_unique_constraintsRsz$Dialect.get_multi_unique_constraintszList[ReflectedCheckConstraint]cKs tdS)aReturn information about check constraints in ``table_name``. Given a string ``table_name`` and an optional string ``schema``, return check constraint information as a list of dicts corresponding to the :class:`.ReflectedCheckConstraint` dictionary. This is an internal dialect method. Applications should use :meth:`.Inspector.get_check_constraints`. NrrrIrIrJget_check_constraintsnszDialect.get_check_constraintsz9Iterable[Tuple[TableKey, List[ReflectedCheckConstraint]]]cKs tdS)aReturn information about check constraints in all tables in the given ``schema``. This is an internal dialect method. Applications should use :meth:`.Inspector.get_multi_check_constraints`. .. note:: The :class:`_engine.DefaultDialect` provides a default implementation that will call the single table method for each object returned by :meth:`Dialect.get_table_names`, :meth:`Dialect.get_view_names` or :meth:`Dialect.get_materialized_view_names` depending on the provided ``kind``. Dialects that want to support a faster implementation should implement this method. .. versionadded:: 2.0 NrrrIrIrJget_multi_check_constraintssz#Dialect.get_multi_check_constraintsDict[str, Any]cKs tdS)zReturn a dictionary of options specified when ``table_name`` was created. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_table_options`. NrrrIrIrJget_table_optionss zDialect.get_table_optionsz)Iterable[Tuple[TableKey, Dict[str, Any]]]cKs tdS)aReturn a dictionary of options specified when the tables in the given schema were created. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_multi_table_options`. .. note:: The :class:`_engine.DefaultDialect` provides a default implementation that will call the single table method for each object returned by :meth:`Dialect.get_table_names`, :meth:`Dialect.get_view_names` or :meth:`Dialect.get_materialized_view_names` depending on the provided ``kind``. Dialects that want to support a faster implementation should implement this method. .. versionadded:: 2.0 NrrrIrIrJget_multi_table_optionsszDialect.get_multi_table_optionsrcKs tdS)aReturn the "comment" for the table identified by ``table_name``. Given a string ``table_name`` and an optional string ``schema``, return table comment information as a dictionary corresponding to the :class:`.ReflectedTableComment` dictionary. This is an internal dialect method. Applications should use :meth:`.Inspector.get_table_comment`. :raise: ``NotImplementedError`` for dialects that don't support comments. .. versionadded:: 1.2 NrrrIrIrJget_table_commentszDialect.get_table_commentz0Iterable[Tuple[TableKey, ReflectedTableComment]]cKs tdS)aReturn information about the table comment in all tables in the given ``schema``. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.get_multi_table_comment`. .. note:: The :class:`_engine.DefaultDialect` provides a default implementation that will call the single table method for each object returned by :meth:`Dialect.get_table_names`, :meth:`Dialect.get_view_names` or :meth:`Dialect.get_materialized_view_names` depending on the provided ``kind``. Dialects that want to support a faster implementation should implement this method. .. versionadded:: 2.0 NrrrIrIrJget_multi_table_commentszDialect.get_multi_table_comment)rrPcCs tdS)zconvert the given name to lowercase if it is detected as case insensitive. This method is only used if the dialect defines requires_name_normalize=True. NrrSrrIrIrJnormalize_nameszDialect.normalize_namecCs tdS)zconvert the given name to a case insensitive identifier for the backend if it is an all-lowercase name. This method is only used if the dialect defines requires_name_normalize=True. NrrrIrIrJdenormalize_nameszDialect.denormalize_namecKs tdS)aFor internal dialect use, check the existence of a particular table or view in the database. Given a :class:`_engine.Connection` object, a string table_name and optional schema name, return True if the given table exists in the database, False otherwise. This method serves as the underlying implementation of the public facing :meth:`.Inspector.has_table` method, and is also used internally to implement the "checkfirst" behavior for methods like :meth:`_schema.Table.create` and :meth:`_schema.MetaData.create_all`. .. note:: This method is used internally by SQLAlchemy, and is published so that third-party dialects may provide an implementation. It is **not** the public API for checking for table presence. Please use the :meth:`.Inspector.has_table` method. .. versionchanged:: 2.0:: :meth:`_engine.Dialect.has_table` now formally supports checking for additional table-like objects: * any type of views (plain or materialized) * temporary tables of any kind Previously, these two checks were not formally specified and different dialects would vary in their behavior. The dialect testing suite now includes tests for all of these object types, and dialects to the degree that the backing database supports views or temporary tables should seek to support locating these objects for full compliance. NrrrIrIrJ has_tables'zDialect.has_table)rr index_namerrrPcKs tdS)aCheck the existence of a particular index name in the database. Given a :class:`_engine.Connection` object, a string ``table_name`` and string index name, return ``True`` if an index of the given name on the given table exists, ``False`` otherwise. The :class:`.DefaultDialect` implements this in terms of the :meth:`.Dialect.has_table` and :meth:`.Dialect.get_indexes` methods, however dialects can implement a more performant version. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.has_index`. .. versionadded:: 1.4 Nr)rSrrrrrrIrIrJ has_index:szDialect.has_index)r sequence_namerrrPcKs tdS)apCheck the existence of a particular sequence in the database. Given a :class:`_engine.Connection` object and a string `sequence_name`, return ``True`` if the given sequence exists in the database, ``False`` otherwise. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.has_sequence`. Nr)rSrrrrrIrIrJ has_sequenceUszDialect.has_sequence)r schema_namerrPcKs tdS)avCheck the existence of a particular schema name in the database. Given a :class:`_engine.Connection` object, a string ``schema_name``, return ``True`` if a schema of the given exists, ``False`` otherwise. The :class:`.DefaultDialect` implements this by checking the presence of ``schema_name`` among the schemas returned by :meth:`.Dialect.get_schema_names`, however dialects can implement a more performant version. This is an internal dialect method. Applications should use :meth:`_engine.Inspector.has_schema`. .. versionadded:: 2.0 Nr)rSrrrrIrIrJ has_schemahszDialect.has_schemacCs tdS)zRetrieve the server version info from the given connection. This is used by the default implementation to populate the "server_version_info" attribute and is called exactly once upon first connect. NrrrIrIrJ_get_server_version_infos z Dialect._get_server_version_infocCs tdS)aReturn the string name of the currently selected schema from the given connection. This is used by the default implementation to populate the "default_schema_name" attribute and is called exactly once upon first connect. NrrrIrIrJ_get_default_schema_names z Dialect._get_default_schema_namer)dbapi_connectionrPcCs tdS)aProvide an implementation of ``connection.begin()``, given a DB-API connection. The DBAPI has no dedicated "begin" method and it is expected that transactions are implicit. This hook is provided for those DBAPIs that might need additional help in this area. :param dbapi_connection: a DBAPI connection, typically proxied within a :class:`.ConnectionFairy`. NrrSrrIrIrJdo_begins zDialect.do_begincCs tdS)zProvide an implementation of ``connection.rollback()``, given a DB-API connection. :param dbapi_connection: a DBAPI connection, typically proxied within a :class:`.ConnectionFairy`. NrrrIrIrJ do_rollbacks zDialect.do_rollbackcCs tdS)zProvide an implementation of ``connection.commit()``, given a DB-API connection. :param dbapi_connection: a DBAPI connection, typically proxied within a :class:`.ConnectionFairy`. NrrrIrIrJ do_commits zDialect.do_commitrMcCs tdS)aProvide an implementation of ``connection.close()`` that tries as much as possible to not block, given a DBAPI connection. In the vast majority of cases this just calls .close(), however for some asyncio dialects may call upon different API features. This hook is called by the :class:`_pool.Pool` when a connection is being recycled or has been invalidated. .. versionadded:: 1.4.41 NrrrIrIrJ do_terminateszDialect.do_terminatecCs tdS)a Provide an implementation of ``connection.close()``, given a DBAPI connection. This hook is called by the :class:`_pool.Pool` when a connection has been detached from the pool, or is being returned beyond the normal capacity of the pool. NrrrIrIrJdo_closes zDialect.do_closecCs tdSrQrrrIrIrJ_do_ping_w_eventszDialect._do_ping_w_eventcCs tdS)zNping the DBAPI connection and return True if the connection is usable.NrrrIrIrJdo_pingszDialect.do_pingrW_GenericSetInputSizesTypeExecutionContext)rXlist_of_tuplescontextrPcCs tdS)aJinvoke the cursor.setinputsizes() method with appropriate arguments This hook is called if the :attr:`.Dialect.bind_typing` attribute is set to the :attr:`.BindTyping.SETINPUTSIZES` value. Parameter data is passed in a list of tuples (paramname, dbtype, sqltype), where ``paramname`` is the key of the parameter in the statement, ``dbtype`` is the DBAPI datatype and ``sqltype`` is the SQLAlchemy type. The order of tuples is in the correct parameter order. .. versionadded:: 1.4 .. versionchanged:: 2.0 - setinputsizes mode is now enabled by setting :attr:`.Dialect.bind_typing` to :attr:`.BindTyping.SETINPUTSIZES`. Dialects which accept a ``use_setinputsizes`` parameter should set this value appropriately. Nr)rSrXrrrIrIrJdo_set_input_sizesszDialect.do_set_input_sizescCs tdS)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. NrrRrIrIrJ create_xidszDialect.create_xid)rrrPcCs tdS)zCreate a savepoint with the given name. :param connection: a :class:`_engine.Connection`. :param name: savepoint name. NrrSrrrIrIrJ do_savepointszDialect.do_savepointcCs tdS)zRollback a connection to the named savepoint. :param connection: a :class:`_engine.Connection`. :param name: savepoint name. NrrrIrIrJdo_rollback_to_savepoints z Dialect.do_rollback_to_savepointcCs tdS)zRelease the named savepoint on a connection. :param connection: a :class:`_engine.Connection`. :param name: savepoint name. NrrrIrIrJdo_release_savepointszDialect.do_release_savepoint)rxidrPcCs tdS)zBegin a two phase transaction on the given connection. :param connection: a :class:`_engine.Connection`. :param xid: xid NrrSrrrIrIrJdo_begin_twophase&szDialect.do_begin_twophasecCs tdS)zPrepare a two phase transaction on the given connection. :param connection: a :class:`_engine.Connection`. :param xid: xid NrrrIrIrJdo_prepare_twophase0szDialect.do_prepare_twophase)rr is_preparedrecoverrPcCs tdS)a3Rollback a two phase transaction on the given connection. :param connection: a :class:`_engine.Connection`. :param xid: xid :param is_prepared: whether or not :meth:`.TwoPhaseTransaction.prepare` was called. :param recover: if the recover flag was passed. NrrSrrrr rIrIrJdo_rollback_twophase:szDialect.do_rollback_twophasecCs tdS)a2Commit a two phase transaction on the given connection. :param connection: a :class:`_engine.Connection`. :param xid: xid :param is_prepared: whether or not :meth:`.TwoPhaseTransaction.prepare` was called. :param recover: if the recover flag was passed. Nrr rIrIrJdo_commit_twophaseMszDialect.do_commit_twophasez List[Any]cCs tdS)zRecover list of uncommitted prepared two phase transaction identifiers on the given connection. :param connection: a :class:`_engine.Connection`. NrrrIrIrJdo_recover_twophaseaszDialect.do_recover_twophaserfz#Optional[_GenericSetInputSizesType]z Iterator[_InsertManyValuesBatch])rrX statementrcgeneric_setinputsizesrrPcCs tdS)zconvert executemany parameters for an INSERT into an iterator of statement/single execute values, used by the insertmanyvalues feature. Nr)rSrrXrrcrrrIrIrJ!_deliver_insertmanyvalues_batchesksz)Dialect._deliver_insertmanyvalues_batchesOptional[ExecutionContext])rXrrcrrPcCs tdS)zSProvide an implementation of ``cursor.executemany(statement, parameters)``.NrrSrXrrcrrIrIrJdo_executemany{s zDialect.do_executemanyracCs tdS)zOProvide an implementation of ``cursor.execute(statement, parameters)``.NrrrIrIrJ do_executes zDialect.do_execute)rXrrrPcCs tdS)z{Provide an implementation of ``cursor.execute(statement)``. The parameter collection should not be sent. Nr)rSrXrrrIrIrJdo_execute_no_paramss zDialect.do_execute_no_params Exceptionz7Optional[Union[PoolProxiedConnection, DBAPIConnection]]Optional[DBAPICursor])errXrPcCs tdS)zMReturn True if the given DB-API error indicates an invalid connectionNr)rSrrrXrIrIrJ is_disconnects zDialect.is_disconnect)cargscparamsrPcOs tdS)aEstablish a connection using this dialect's DBAPI. The default implementation of this method is:: def connect(self, *cargs, **cparams): return self.dbapi.connect(*cargs, **cparams) The ``*cargs, **cparams`` parameters are generated directly from this dialect's :meth:`.Dialect.create_connect_args` method. This method may be used for dialects that need to perform programmatic per-connection steps when a new connection is procured from the DBAPI. :param \*cargs: positional parameters returned from the :meth:`.Dialect.create_connect_args` method :param \*\*cparams: keyword parameters returned from the :meth:`.Dialect.create_connect_args` method. :return: a DBAPI connection, typically from the :pep:`249` module level ``.connect()`` function. .. seealso:: :meth:`.Dialect.create_connect_args` :meth:`.Dialect.on_connect` Nr)rSrrrIrIrJconnects zDialect.connectzOptional[Callable[[Any], Any]]cCs|S)a& return a callable which sets up a newly created DBAPI connection. This method is a new hook that supersedes the :meth:`_engine.Dialect.on_connect` method when implemented by a dialect. When not implemented by a dialect, it invokes the :meth:`_engine.Dialect.on_connect` method directly to maintain compatibility with existing dialects. There is no deprecation for :meth:`_engine.Dialect.on_connect` expected. The callable should accept a single argument "conn" which is the DBAPI connection itself. The inner callable has no return value. E.g.:: class MyDialect(default.DefaultDialect): # ... def on_connect_url(self, url): def do_on_connect(connection): connection.execute("SET SPECIAL FLAGS etc") return do_on_connect This is used to set dialect-wide per-connection options such as isolation modes, Unicode modes, etc. This method differs from :meth:`_engine.Dialect.on_connect` in that it is passed the :class:`_engine.URL` object that's relevant to the connect args. Normally the only way to get this is from the :meth:`_engine.Dialect.on_connect` hook is to look on the :class:`_engine.Engine` itself, however this URL object may have been replaced by plugins. .. note:: The default implementation of :meth:`_engine.Dialect.on_connect_url` is to invoke the :meth:`_engine.Dialect.on_connect` method. Therefore if a dialect implements this method, the :meth:`_engine.Dialect.on_connect` method **will not be called** unless the overriding dialect calls it directly from here. .. versionadded:: 1.4.3 added :meth:`_engine.Dialect.on_connect_url` which normally calls into :meth:`_engine.Dialect.on_connect`. :param url: a :class:`_engine.URL` object representing the :class:`_engine.URL` that was passed to the :meth:`_engine.Dialect.create_connect_args` method. :return: a callable that accepts a single DBAPI connection as an argument, or None. .. seealso:: :meth:`_engine.Dialect.on_connect` ) on_connectrrIrIrJon_connect_urls;zDialect.on_connect_urlcCsdS)areturn a callable which sets up a newly created DBAPI connection. The callable should accept a single argument "conn" which is the DBAPI connection itself. The inner callable has no return value. E.g.:: class MyDialect(default.DefaultDialect): # ... def on_connect(self): def do_on_connect(connection): connection.execute("SET SPECIAL FLAGS etc") return do_on_connect This is used to set dialect-wide per-connection options such as isolation modes, Unicode modes, etc. The "do_on_connect" callable is invoked by using the :meth:`_events.PoolEvents.connect` event hook, then unwrapping the DBAPI connection and passing it into the callable. .. versionchanged:: 1.4 the on_connect hook is no longer called twice for the first connection of a dialect. The on_connect hook is still called before the :meth:`_engine.Dialect.initialize` method however. .. versionchanged:: 1.4.3 the on_connect hook is invoked from a new method on_connect_url that passes the URL that was used to create the connect args. Dialects can implement on_connect_url instead of on_connect if they need the URL object that was used for the connection in order to get additional context. If None is returned, no event listener is generated. :return: a callable that accepts a single DBAPI connection as an argument, or None. .. seealso:: :meth:`.Dialect.connect` - allows the DBAPI ``connect()`` sequence itself to be controlled. :meth:`.Dialect.on_connect_url` - supersedes :meth:`.Dialect.on_connect` to also receive the :class:`_engine.URL` object in context. NrIrRrIrIrJr s3zDialect.on_connectcCs tdS)a2Given a DBAPI connection, revert its isolation to the default. Note that this is a dialect-level method which is used as part of the implementation of the :class:`_engine.Connection` and :class:`_engine.Engine` isolation level facilities; these APIs should be preferred for most typical use cases. .. seealso:: :meth:`_engine.Connection.get_isolation_level` - view current level :attr:`_engine.Connection.default_isolation_level` - view default level :paramref:`.Connection.execution_options.isolation_level` - set per :class:`_engine.Connection` isolation level :paramref:`_sa.create_engine.isolation_level` - set per :class:`_engine.Engine` isolation level NrrrIrIrJreset_isolation_level@ szDialect.reset_isolation_levelr})rlevelrPcCs tdS)a2Given a DBAPI connection, set its isolation level. Note that this is a dialect-level method which is used as part of the implementation of the :class:`_engine.Connection` and :class:`_engine.Engine` isolation level facilities; these APIs should be preferred for most typical use cases. If the dialect also implements the :meth:`.Dialect.get_isolation_level_values` method, then the given level is guaranteed to be one of the string names within that sequence, and the method will not need to anticipate a lookup failure. .. seealso:: :meth:`_engine.Connection.get_isolation_level` - view current level :attr:`_engine.Connection.default_isolation_level` - view default level :paramref:`.Connection.execution_options.isolation_level` - set per :class:`_engine.Connection` isolation level :paramref:`_sa.create_engine.isolation_level` - set per :class:`_engine.Engine` isolation level Nr)rSrr rIrIrJset_isolation_level[ s zDialect.set_isolation_levelcCs tdS)aGiven a DBAPI connection, return its isolation level. When working with a :class:`_engine.Connection` object, the corresponding DBAPI connection may be procured using the :attr:`_engine.Connection.connection` accessor. Note that this is a dialect-level method which is used as part of the implementation of the :class:`_engine.Connection` and :class:`_engine.Engine` isolation level facilities; these APIs should be preferred for most typical use cases. .. seealso:: :meth:`_engine.Connection.get_isolation_level` - view current level :attr:`_engine.Connection.default_isolation_level` - view default level :paramref:`.Connection.execution_options.isolation_level` - set per :class:`_engine.Connection` isolation level :paramref:`_sa.create_engine.isolation_level` - set per :class:`_engine.Engine` isolation level NrrrIrIrJget_isolation_level} s!zDialect.get_isolation_level) dbapi_connrPcCs tdS)aGiven a DBAPI connection, return its isolation level, or a default isolation level if one cannot be retrieved. This method may only raise NotImplementedError and **must not raise any other exception**, as it is used implicitly upon first connect. The method **must return a value** for a dialect that supports isolation level settings, as this level is what will be reverted towards when a per-connection isolation level change is made. The method defaults to using the :meth:`.Dialect.get_isolation_level` method unless overridden by a dialect. .. versionadded:: 1.3.22 NrrSr#rIrIrJget_default_isolation_level sz#Dialect.get_default_isolation_levelzList[IsolationLevel]cCs tdS)areturn a sequence of string isolation level names that are accepted by this dialect. The available names should use the following conventions: * use UPPERCASE names. isolation level methods will accept lowercase names but these are normalized into UPPERCASE before being passed along to the dialect. * separate words should be separated by spaces, not underscores, e.g. ``REPEATABLE READ``. isolation level names will have underscores converted to spaces before being passed along to the dialect. * The names for the four standard isolation names to the extent that they are supported by the backend should be ``READ UNCOMMITTED`` ``READ COMMITTED``, ``REPEATABLE READ``, ``SERIALIZABLE`` * if the dialect supports an autocommit option it should be provided using the isolation level name ``AUTOCOMMIT``. * Other isolation modes may also be present, provided that they are named in UPPERCASE and use spaces not underscores. This function is used so that the default dialect can check that a given isolation level parameter is valid, else raises an :class:`_exc.ArgumentError`. A DBAPI connection is passed to the method, in the unlikely event that the dialect needs to interrogate the connection itself to determine this list, however it is expected that most backends will return a hardcoded list of values. If the dialect supports "AUTOCOMMIT", that value should also be present in the sequence returned. The method raises ``NotImplementedError`` by default. If a dialect does not implement this method, then the default dialect will not perform any checking on a given isolation level value before passing it onto the :meth:`.Dialect.set_isolation_level` method. This is to allow backwards-compatibility with third party dialects that may not yet be implementing this method. .. versionadded:: 2.0 Nrr$rIrIrJget_isolation_level_values s*z"Dialect.get_isolation_level_values)r#r rPcCs tdSrQr)rSr#r rIrIrJ_assert_and_set_isolation_level sz'Dialect._assert_and_set_isolation_level Type[Dialect]cCs|S)a}Given a URL, return the :class:`.Dialect` that will be used. This is a hook that allows an external plugin to provide functionality around an existing dialect, by allowing the plugin to be loaded from the url based on an entrypoint, and then the plugin returns the actual dialect to be used. By default this just returns the cls. rIrrrIrIrJget_dialect_cls s zDialect.get_dialect_clscCs ||S)aGiven a URL, return the :class:`.Dialect` that will be used by an async engine. By default this is an alias of :meth:`.Dialect.get_dialect_cls` and just returns the cls. It may be used if a dialect provides both a sync and async version under the same name, like the ``psycopg`` driver. .. versionadded:: 2 .. seealso:: :meth:`.Dialect.get_dialect_cls` )r*r)rIrIrJget_async_dialect_cls szDialect.get_async_dialect_clscCsdS)aJset up the provision.py module for this dialect. For dialects that include a provision.py module that sets up provisioning followers, this method should initiate that process. A typical implementation would be:: @classmethod def load_provisioning(cls): __import__("mydialect.provision") The default method assumes a module named ``provision.py`` inside the owning package of the current dialect, based on the ``__module__`` attribute:: @classmethod def load_provisioning(cls): package = ".".join(cls.__module__.split(".")[0:-1]) try: __import__(package + ".provision") except ImportError: pass .. versionadded:: 1.3.14 NrIrrIrIrJload_provisioning szDialect.load_provisioningr'enginerPcCsdS)a_A convenience hook called before returning the final :class:`_engine.Engine`. If the dialect returned a different class from the :meth:`.get_dialect_cls` method, then the hook is called on both classes, first on the dialect class returned by the :meth:`.get_dialect_cls` method and then on the class on which the method was called. The hook should be used by dialects and/or wrappers to apply special events to the engine or its components. In particular, it allows a dialect-wrapping class to apply dialect-level events. NrI)rr.rIrIrJengine_created% szDialect.engine_createdcCs tdS)aReturns the connection object as returned by the external driver package. For normal dialects that use a DBAPI compliant driver this call will just return the ``connection`` passed as argument. For dialects that instead adapt a non DBAPI compliant driver, like when adapting an asyncio driver, this call will return the connection-like object as returned by the driver. .. versionadded:: 1.4.24 NrrrIrIrJget_driver_connection6 s zDialect.get_driver_connectionCoreExecuteOptionsParameter)r.optsrPcCs tdS)aaEstablish execution options for a given engine. This is implemented by :class:`.DefaultDialect` to establish event hooks for new :class:`.Connection` instances created by the given :class:`.Engine` which will then invoke the :meth:`.Dialect.set_connection_execution_options` method for that connection. Nr)rSr.r2rIrIrJset_engine_execution_optionsE s z$Dialect.set_engine_execution_options)rr2rPcCs tdS)aEstablish execution options for a given connection. This is implemented by :class:`.DefaultDialect` in order to implement the :paramref:`_engine.Connection.execution_options.isolation_level` execution option. Dialects can intercept various execution options which may need to modify state on a particular DBAPI connection. .. versionadded:: 1.4 Nr)rSrr2rIrIrJ set_connection_execution_optionsS s z(Dialect.set_connection_execution_options Type[Pool]cCs tdS)z*return a Pool class to use for a given URLNrrrIrIrJget_dialect_pool_classb szDialect.get_dialect_pool_class)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)TF)TF)N)N)N)grArBrCrLr>rDrErFrGrHr[rZnon_memoized_propertyrrrr EMPTY_DICTrZ _has_eventsrrrZ bind_typingrr classmethodrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r rrrrrrrrrr!r"r%r&r'r*r+r,r/r0r3r4r6rIrIrIrJrss           %    !        .           &"" "=5"#, rc@sdeZdZdZdddddZddddd Zd dd d d dZddd dddZdd dddZdS)CreateEnginePluginaA set of hooks intended to augment the construction of an :class:`_engine.Engine` object based on entrypoint names in a URL. The purpose of :class:`_engine.CreateEnginePlugin` is to allow third-party systems to apply engine, pool and dialect level event listeners without the need for the target application to be modified; instead, the plugin names can be added to the database URL. Target applications for :class:`_engine.CreateEnginePlugin` include: * connection and SQL performance tools, e.g. which use events to track number of checkouts and/or time spent with statements * connectivity plugins such as proxies A rudimentary :class:`_engine.CreateEnginePlugin` that attaches a logger to an :class:`_engine.Engine` object might look like:: import logging from sqlalchemy.engine import CreateEnginePlugin from sqlalchemy import event class LogCursorEventsPlugin(CreateEnginePlugin): def __init__(self, url, kwargs): # consume the parameter "log_cursor_logging_name" from the # URL query logging_name = url.query.get("log_cursor_logging_name", "log_cursor") self.log = logging.getLogger(logging_name) def update_url(self, url): "update the URL to one that no longer includes our parameters" return url.difference_update_query(["log_cursor_logging_name"]) def engine_created(self, engine): "attach an event listener after the new Engine is constructed" event.listen(engine, "before_cursor_execute", self._log_event) def _log_event( self, conn, cursor, statement, parameters, context, executemany): self.log.info("Plugin logged cursor event: %s", statement) Plugins are registered using entry points in a similar way as that of dialects:: entry_points={ 'sqlalchemy.plugins': [ 'log_cursor_plugin = myapp.plugins:LogCursorEventsPlugin' ] A plugin that uses the above names would be invoked from a database URL as in:: from sqlalchemy import create_engine engine = create_engine( "mysql+pymysql://scott:tiger@localhost/test?" "plugin=log_cursor_plugin&log_cursor_logging_name=mylogger" ) The ``plugin`` URL parameter supports multiple instances, so that a URL may specify multiple plugins; they are loaded in the order stated in the URL:: engine = create_engine( "mysql+pymysql://scott:tiger@localhost/test?" "plugin=plugin_one&plugin=plugin_twp&plugin=plugin_three") The plugin names may also be passed directly to :func:`_sa.create_engine` using the :paramref:`_sa.create_engine.plugins` argument:: engine = create_engine( "mysql+pymysql://scott:tiger@localhost/test", plugins=["myplugin"]) .. versionadded:: 1.2.3 plugin names can also be specified to :func:`_sa.create_engine` as a list A plugin may consume plugin-specific arguments from the :class:`_engine.URL` object as well as the ``kwargs`` dictionary, which is the dictionary of arguments passed to the :func:`_sa.create_engine` call. "Consuming" these arguments includes that they must be removed when the plugin initializes, so that the arguments are not passed along to the :class:`_engine.Dialect` constructor, where they will raise an :class:`_exc.ArgumentError` because they are not known by the dialect. As of version 1.4 of SQLAlchemy, arguments should continue to be consumed from the ``kwargs`` dictionary directly, by removing the values with a method such as ``dict.pop``. Arguments from the :class:`_engine.URL` object should be consumed by implementing the :meth:`_engine.CreateEnginePlugin.update_url` method, returning a new copy of the :class:`_engine.URL` with plugin-specific parameters removed:: class MyPlugin(CreateEnginePlugin): def __init__(self, url, kwargs): self.my_argument_one = url.query['my_argument_one'] self.my_argument_two = url.query['my_argument_two'] self.my_argument_three = kwargs.pop('my_argument_three', None) def update_url(self, url): return url.difference_update_query( ["my_argument_one", "my_argument_two"] ) Arguments like those illustrated above would be consumed from a :func:`_sa.create_engine` call such as:: from sqlalchemy import create_engine engine = create_engine( "mysql+pymysql://scott:tiger@localhost/test?" "plugin=myplugin&my_argument_one=foo&my_argument_two=bar", my_argument_three='bat' ) .. versionchanged:: 1.4 The :class:`_engine.URL` object is now immutable; a :class:`_engine.CreateEnginePlugin` that needs to alter the :class:`_engine.URL` should implement the newly added :meth:`_engine.CreateEnginePlugin.update_url` method, which is invoked after the plugin is constructed. For migration, construct the plugin in the following way, checking for the existence of the :meth:`_engine.CreateEnginePlugin.update_url` method to detect which version is running:: class MyPlugin(CreateEnginePlugin): def __init__(self, url, kwargs): if hasattr(CreateEnginePlugin, "update_url"): # detect the 1.4 API self.my_argument_one = url.query['my_argument_one'] self.my_argument_two = url.query['my_argument_two'] else: # detect the 1.3 and earlier API - mutate the # URL directly self.my_argument_one = url.query.pop('my_argument_one') self.my_argument_two = url.query.pop('my_argument_two') self.my_argument_three = kwargs.pop('my_argument_three', None) def update_url(self, url): # this method is only called in the 1.4 version return url.difference_update_query( ["my_argument_one", "my_argument_two"] ) .. seealso:: :ref:`change_5526` - overview of the :class:`_engine.URL` change which also includes notes regarding :class:`_engine.CreateEnginePlugin`. When the engine creation process completes and produces the :class:`_engine.Engine` object, it is again passed to the plugin via the :meth:`_engine.CreateEnginePlugin.engine_created` hook. In this hook, additional changes can be made to the engine, most typically involving setup of events (e.g. those defined in :ref:`core_event_toplevel`). r)r)rkwargscCs ||_dS)aConstruct a new :class:`.CreateEnginePlugin`. The plugin object is instantiated individually for each call to :func:`_sa.create_engine`. A single :class:`_engine. Engine` will be passed to the :meth:`.CreateEnginePlugin.engine_created` method corresponding to this URL. :param url: the :class:`_engine.URL` object. The plugin may inspect the :class:`_engine.URL` for arguments. Arguments used by the plugin should be removed, by returning an updated :class:`_engine.URL` from the :meth:`_engine.CreateEnginePlugin.update_url` method. .. versionchanged:: 1.4 The :class:`_engine.URL` object is now immutable, so a :class:`_engine.CreateEnginePlugin` that needs to alter the :class:`_engine.URL` object should implement the :meth:`_engine.CreateEnginePlugin.update_url` method. :param kwargs: The keyword arguments passed to :func:`_sa.create_engine`. N)r)rSrr:rIrIrJ__init__ szCreateEnginePlugin.__init__rcCs tdS)aUpdate the :class:`_engine.URL`. A new :class:`_engine.URL` should be returned. This method is typically used to consume configuration arguments from the :class:`_engine.URL` which must be removed, as they will not be recognized by the dialect. The :meth:`_engine.URL.difference_update_query` method is available to remove these arguments. See the docstring at :class:`_engine.CreateEnginePlugin` for an example. .. versionadded:: 1.4 NrrrIrIrJ update_url/ szCreateEnginePlugin.update_urlr(rN) dialect_cls dialect_argsrPcCsdS)zparse and modify dialect kwargsNrI)rSr=r>rIrIrJhandle_dialect_kwargs@ sz(CreateEnginePlugin.handle_dialect_kwargsr5)pool_cls pool_argsrPcCsdS)zparse and modify pool kwargsNrI)rSr@rArIrIrJhandle_pool_kwargsE sz%CreateEnginePlugin.handle_pool_kwargsr'r-cCsdS)zReceive the :class:`_engine.Engine` object when it is fully constructed. The plugin may make additional changes to the engine, such as registering engine or connection pool events. NrI)rSr.rIrIrJr/J sz!CreateEnginePlugin.engine_createdN) rArBrCrLr;r<r?rBr/rIrIrIrJr9g s-r9c @seZdZUdZded<ded<ded<ded<d ed <d ed <d ed<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<eddddd dd!d"d#Zeejfddddd$d%d&d'd(dd) d*d+Z eddddd d,dd-d.d/Z edddddd0d1d2Z d3d4d5d6d7d8d9Z d:d;dd?Zd@d;dAdBZdCdDdEdFdGdHZd d;dIdJZdKd;dLdMZdNdOdPdQdRZdKd;dSdTZdUdKdVdWdXZdd;dYdZZd[d;d\d]Zd dOd^d_d`ZdaS)brzRA messenger object for a Dialect that corresponds to a single execution. r'r.r&rZroot_connectionrdialectrWrXzOptional[Compiled]compiledrqrzOptional[Executable]invoked_statement_AnyMultiExecuteParamsrcrZr~ZisinsertZisupdaterKZ execute_stylergz;util.generic_fn_descriptor[Optional[Sequence[Column[Any]]]]Z prefetch_colsZpostfetch_cols_ExecuteOptionsexecution_optionsrr/)rCrrrH compiled_ddlrPcCs tdSrQr)rrCrrrHrIrIrIrJ _init_ddl s zExecutionContext._init_ddlr3_CoreMultiExecuteParamsr-z&Optional[Sequence[BindParameter[Any]]]r>) rCrrrHrDrcrEextracted_parameters cache_hitrPc Cs tdSrQr) rrCrrrHrDrcrErLrMrIrIrJ_init_compiled s zExecutionContext._init_compiledrf)rCrrrHrrcrPcCs tdSrQr)rrCrrrHrrcrIrIrJ_init_statement s z ExecutionContext._init_statement)rCrrrHrPcCs tdSrQr)rrCrrrHrIrIrJ _init_default szExecutionContext._init_defaultzOptional[Column[Any]]r7zOptional[TypeEngine[Any]]r)rortype_rPcCs tdSrQr)rSrorrQrIrIrJ _exec_default szExecutionContext._exec_defaultz0Optional[List[Tuple[str, Any, TypeEngine[Any]]]]rOcCs tdSrQrrRrIrIrJ_prepare_set_input_sizes sz)ExecutionContext._prepare_set_input_sizescCs tdSrQrrRrIrIrJ_get_cache_stats sz!ExecutionContext._get_cache_statszCursorResult[Any]cCs tdSrQrrRrIrIrJ_setup_result_proxy sz$ExecutionContext._setup_result_proxySequence_SchemaItemr9r_)seqrQrPcCs tdS)zKgiven a :class:`.Sequence`, invoke it and return the next int valueNr)rSrWrQrIrIrJ fire_sequence szExecutionContext.fire_sequencecCs tdS)zReturn a new cursor generated from this ExecutionContext's connection. Some dialects may wish to change the behavior of connection.cursor(), such as postgresql which may return a PG "server side" cursor. NrrRrIrIrJ create_cursor s zExecutionContext.create_cursorrNcCs tdS)zCalled before an execution of a compiled statement. If a compiled statement was passed to this ExecutionContext, the `statement` and `parameters` datamembers must be initialized after this statement is complete. NrrRrIrIrJpre_exec szExecutionContext.pre_execrri)out_param_namesrPcCs tdS)a!Return a sequence of OUT parameter values from a cursor. For dialects that support OUT parameters, this method will be called when there is a :class:`.SQLCompiler` object which has the :attr:`.SQLCompiler.has_out_parameters` flag set. This flag in turn will be set to True if the statement itself has :class:`.BindParameter` objects that have the ``.isoutparam`` flag set which are consumed by the :meth:`.SQLCompiler.visit_bindparam` method. If the dialect compiler produces :class:`.BindParameter` objects with ``.isoutparam`` set which are not handled by :meth:`.SQLCompiler.visit_bindparam`, it should set this flag explicitly. The list of names that were rendered for each bound parameter is passed to the method. The method should then return a sequence of values corresponding to the list of parameter objects. Unlike in previous SQLAlchemy versions, the values can be the **raw values** from the DBAPI; the execution context will apply the appropriate type handler based on what's present in self.compiled.binds and update the values. The processed dictionary will then be made available via the ``.out_parameters`` collection on the result object. Note that SQLAlchemy 1.4 has multiple kinds of result object as part of the 2.0 transition. .. versionadded:: 1.4 - added :meth:`.ExecutionContext.get_out_parameter_values`, which is invoked automatically by the :class:`.DefaultExecutionContext` when there are :class:`.BindParameter` objects with the ``.isoutparam`` flag set. This replaces the practice of setting out parameters within the now-removed ``get_result_proxy()`` method. Nr)rSr[rIrIrJget_out_parameter_values s"z)ExecutionContext.get_out_parameter_valuescCs tdS)aCalled after the execution of a compiled statement. If a compiled statement was passed to this ExecutionContext, the `last_insert_ids`, `last_inserted_params`, etc. datamembers should be available after this method completes. NrrRrIrIrJ post_exec1 szExecutionContext.post_exec BaseException)rrPcCs tdS)zQReceive a DBAPI exception which occurred upon execute, result fetch, etc.Nr)rSrrIrIrJhandle_dbapi_exception; sz'ExecutionContext.handle_dbapi_exceptioncCs tdS)zjReturn True if the last INSERT or UPDATE row contained inlined or database-side defaults. NrrRrIrIrJlastrow_has_defaultsA sz%ExecutionContext.lastrow_has_defaultsrcCs tdS)zReturn the DBAPI ``cursor.rowcount`` value, or in some cases an interpreted value. See :attr:`_engine.CursorResult.rowcount` for details on this. NrrRrIrIrJ get_rowcountH szExecutionContext.get_rowcount)rXrPcCs tdS)aFor a RETURNING result, deliver cursor.fetchall() from the DBAPI cursor. This is a dialect-specific hook for dialects that have special considerations when calling upon the rows delivered for a "RETURNING" statement. Default implementation is ``cursor.fetchall()``. This hook is currently used only by the :term:`insertmanyvalues` feature. Dialects that don't set ``use_insertmanyvalues=True`` don't need to consider this hook. .. versionadded:: 2.0.10 Nr)rSrXrIrIrJfetchall_for_returningR sz'ExecutionContext.fetchall_for_returningN)rArBrCrLr[r8rJr>rFrNrOrPrRrSrTrUrXrYrZr\r]r_r`rarbrIrIrIrJrT sP      $    $  rc@seZdZUdZded<dS)ConnectionEventsTargetzAn object which can accept events from :class:`.ConnectionEvents`. Includes :class:`_engine.Connection` and :class:`_engine.Engine`. .. versionadded:: 2.0 z"dispatcher[ConnectionEventsTarget]rNrrIrIrIrJrce s rcc@s~eZdZUdZdZded<ded<ded<d ed <d ed <d ed<ded<ded<ded<ded<ded<ded<ded<dS)ExceptionContextaEncapsulate information about an error condition in progress. This object exists solely to be passed to the :meth:`_events.DialectEvents.handle_error` event, supporting an interface that can be extended without backwards-incompatibility. rIrrCzOptional[Connection]rzOptional[Engine]r.rrXrrz Optional[_DBAPIAnyExecuteParams]rcr^Zoriginal_exceptionzOptional[StatementError]Zsqlalchemy_exceptionzOptional[BaseException]Zchained_exceptionrZexecution_contextrZrZinvalidate_pool_on_disconnectZ is_pre_pingN)rArBrCrL __slots__r[rIrIrIrJrdt s      rdc@sNeZdZUdZdZded<eddddZdd d d d Zd dddZ dS)AdaptedConnectionzInterface of an adapted connection object to support the DBAPI protocol. Used by asyncio dialects to provide a sync-style pep-249 facade on top of the asyncio connection/cursor API provided by the driver. .. versionadded:: 1.4.24  _connectionrrhrOcCs|jS)z@The connection object as returned by the driver after a connect.rgrRrIrIrJdriver_connection( sz#AdaptedConnection.driver_connectionzCallable[[Any], Awaitable[_T]]r<)fnrPcCst||jS)aRun the awaitable returned by the given function, which is passed the raw asyncio driver connection. This is used to invoke awaitable-only methods on the driver connection within the context of a "synchronous" method, like a connection pool event handler. E.g.:: engine = create_async_engine(...) @event.listens_for(engine.sync_engine, "connect") def register_custom_types(dbapi_connection, ...): dbapi_connection.run_async( lambda connection: connection.set_type_codec( 'MyCustomType', encoder, decoder, ... ) ) .. versionadded:: 1.4.30 .. seealso:: :ref:`asyncio_events_run_async` )r rh)rSrjrIrIrJ run_async- szAdaptedConnection.run_asyncrqcCs d|jS)NzrgrRrIrIrJ__repr__J szAdaptedConnection.__repr__N) rArBrCrLrer[rwrirkrlrIrIrIrJrf s  rfN)rL __future__renumrtypesrtypingrrrrr r r r r rrrrrrrrrrreventrpoolrrZ sql.compilerrrrZutil.concurrencyr Z util.typingr!r"r#r$baser&r'rXr(rr)r*r+excr,sqlr-r.r/r0r1r2r3Z sql.elementsr4r5Z sql.schemar6r7r8rVZ sql.sqltypesr9Z sql.type_apir:r;rqrr<r>rKrMr\rWZ_CoreSingleExecuteParamsZ_MutableCoreSingleExecuteParamsrKZ_CoreAnyExecuteParamsZ_DBAPISingleExecuteParamsrfZ_DBAPIAnyExecuteParamsr_rZr]Z_AnySingleExecuteParamsrFZ_AnyExecuteParamsZCompiledCacheTypeZSchemaTranslateMapTypeZ_ImmutableExecuteOptionsZ _ParamStylerr}r|rGr1rrrrrrrrrrrZVersionInfoTypeZTableKeyrr9rrcZ ConnectablerdrfrIrIrIrJs,                                                             C       .:4 <n '