Files
aitsc/.venv/Lib/site-packages/sqlalchemy/engine/__pycache__/interfaces.cpython-312.pyc

1678 lines
100 KiB
Plaintext
Raw Normal View History

2025-02-23 09:07:52 +08:00
<EFBFBD>
2025-08-29 00:34:40 +08:00
<00><19>h7<68><00>
<01><><00>dZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm
2025-02-23 09:07:52 +08:00
Z
2025-08-29 00:34:40 +08:00
dd lm Z dd
lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl m!Z!ddl m"Z"ddl m"Z"ddlm#Z#ddl$m%Z%dd l&m'Z'dd!l&m(Z(dd"l&m)Z)dd#l&m*Z*er<>d$d%l+m,Z,d$d&l+m-Z-d$d'l.m/Z/d$d(l0m1Z1dd)l2m3Z3dd*lm4Z4dd+lm5Z5dd,l6m7Z7dd-l8m9Z9dd.l m:Z:dd/l m;Z;dd0l m<Z<dd1l m=Z=dd2l m>Z>dd3l m?Z?dd4l@mAZAdd5l@mBZBdd6lCmDZDdd7lCmEZEdd8lCmFZFddlCmZGdd9lHmIZIdd:lJmKZKdd;lJmLZLdd<lMmNZNeeeOeeOeffZPed=d><3E>?<3F>ZQGd@<40>dAe<04>ZRGdB<64>dCe<04>ZSGdD<64>dEe)<29>ZTGdF<64>dGe)<29>ZUGdH<64>dIe)<29>ZVGdJ<64>dKe)<29>ZWeeOefZXeeOefZYeeXZZeeZeXfZ[eeeeXfZ\eeeeeZfZ]ee]e\fZ^eeeOdIee_ee_ee_ee_ee`fZae\Zbe]Zce^ZdeedLfZeeeeOeeOfZfe#eOefZge'dMZheeeOedNfZie'dOZjGdP<64>dQe*dR<64>S<EFBFBD>Zke#eOefZleekeeOeffZmGdT<64>dUe*<2A>ZnGdV<64>dWe*<2A>ZoGdX<64>dYe*<2A>ZpGdZ<64>d[e*<2A>ZqGd\<5C>d]eq<65>ZrGd^<5E>d_eq<65>ZsGd`<60>daeq<65>ZtGdb<64>dceq<65>ZuGdd<64>dee*<2A>ZvGdf<64>dge*<2A>ZwGdh<64>die<04>Zxeee_eOfdjfZyeeeOeOfZzGdk<64>dle<1C>Z{Gdm<64>dn<64>Z|Gdo<64>dp<64>Z}Gdq<64>dre<1C>Z~e~ZGds<64>dt<64>Z<>Gdu<64>dv<64>Z<>yw)xz1Define core interfaces used by the engine system.<2E>)<01> annotations)<01>Enum)<01>Any)<01> Awaitable)<01>Callable)<01>ClassVar)<01>
2025-02-23 09:07:52 +08:00
Collection)<01>Dict)<01>Iterable)<01>Iterator)<01>List)<01>Mapping)<01>MutableMapping)<01>Optional)<01>Sequence)<01>Set)<01>Tuple)<01>Type)<01> TYPE_CHECKING)<01>TypeVar)<01>Union<6F>)<01>util)<01> EventTarget)<01>Pool)<01>PoolProxiedConnection)<01>Compiled)<01> TypeCompiler)<01> immutabledict)<01>
await_only)<01>Literal)<01> NotRequired)<01>Protocol)<01> TypedDict<63>)<01>
2025-08-29 00:34:40 +08:00
Connection)<01>Engine)<01> CursorResult)<01>URL)<01>AsyncIODBAPIConnection)<01>_ListenerFnType)<01>
2025-02-23 09:07:52 +08:00
dispatcher)<01>StatementError)<01>
Executable)<01>_InsertManyValuesBatch)<01> DDLCompiler)<01>IdentifierPreparer)<01>InsertmanyvaluesSentinelOpts)<01>Linting)<01> SQLCompiler)<01> BindParameter)<01> ClauseElement)<01>Column)<01>DefaultGenerator)<01>
SchemaItem)<01>Integer)<01> _TypeMemoDict)<01>
2025-08-29 00:34:40 +08:00
TypeEngine)<01>generic_fn_descriptor<6F>_Tr)<01>boundc<01> <00>eZdZdZdZdZdZdZy)<07>
CacheStatsrr%r<00><00>N)<08>__name__<5F>
2025-02-23 09:07:52 +08:00
__module__<EFBFBD> __qualname__<5F> CACHE_HIT<49>
2025-08-29 00:34:40 +08:00
CACHE_MISS<EFBFBD>CACHING_DISABLED<45> NO_CACHE_KEY<45>NO_DIALECT_SUPPORT<52><00><00>ID:\pythonpj\aitsc\.venv\Lib\site-packages\sqlalchemy/engine/interfaces.pyrArAPs<00><00><11>I<EFBFBD><12>J<EFBFBD><18><14><14>L<EFBFBD><1A>rMrAc<01> <00>eZdZdZdZ dZ dZy)<06> ExecuteStylezVindicates the :term:`DBAPI` cursor method that will be used to invoke
a statement.rr%rN)rDrErF<00>__doc__<5F>EXECUTE<54> EXECUTEMANY<4E>INSERTMANYVALUESrLrMrNrPrPXs$<00><00><14><10>G<EFBFBD>1<><13>K<EFBFBD>6<><18><14>rMrPc<01>l<00>eZdZGd<01>de<03>ZGd<03>de<04>ZGd<05>de<04>ZGd<07>de<04>Zd d <09>Zy
) <0C> DBAPIModulec<01><00>eZdZdd<01>Zy)<04>DBAPIModule.Errorc<01><00>y<00>NrL<00><02>self<6C>keys rN<00> __getattr__zDBAPIModule.Error.__getattr__ps<00><00>rMN<>r]<00>str<74>returnr)rDrErFr^rLrMrN<00>ErrorrXos<00><00>3rMrbc<01> <00>eZdZy)<02>DBAPIModule.OperationalErrorN<72>rDrErFrLrMrN<00>OperationalErrorrdr<00><00><00> rMrfc<01> <00>eZdZy)<02>DBAPIModule.InterfaceErrorNrerLrMrN<00>InterfaceErrorriurgrMrjc<01> <00>eZdZy)<02>DBAPIModule.IntegrityErrorNrerLrMrN<00>IntegrityErrorrlxrgrMrmc<01><00>yrZrLr[s rNr^zDBAPIModule.__getattr__{<00><00><00>CrMNr_) rDrErF<00> Exceptionrbrfrjrmr^rLrMrNrVrVns7<00><00>4<> <09>4<> <0A>5<EFBFBD> <0A> <0A><15> <0A> <0A><15> <0A>0rMrVc<01>@<00>eZdZdZd d<02>Zd d<03>Zd
d<04>Zd d<05>Zd d<06>Zd d<07>Z y) <0A>DBAPIConnectionz<6E>protocol representing a :pep:`249` database connection.
2025-02-23 09:07:52 +08:00
.. versionadded:: 2.0
.. seealso::
`Connection Objects <https://www.python.org/dev/peps/pep-0249/#connection-objects>`_
- in :pep:`249`
2025-08-29 00:34:40 +08:00
c<01><00>yrZrL<00>r\s rN<00>closezDBAPIConnection.close<73><00><00><00>SrMc<01><00>yrZrLrts rN<00>commitzDBAPIConnection.commit<69>s<00><00>crMc<01><00>yrZrL)r\<00>args<67>kwargss rN<00>cursorzDBAPIConnection.cursor<6F><00><00><00>rMc<01><00>yrZrLrts rN<00>rollbackzDBAPIConnection.rollback<63>s<00><00>rMc<01><00>yrZrLr[s rNr^zDBAPIConnection.__getattr__<5F>rorMc<01><00>yrZrL)r\r]<00>values rN<00> __setattr__zDBAPIConnection.__setattr__<5F>s<00><00>rMN<>ra<00>None)rzrr{rra<00> DBAPICursorr_)r]r`r<>rrar<>)
rDrErFrQrurxr|rr^r<>rLrMrNrrrr~s<00><00> <08>!<21>!<21>C<>#<23>/<2F><rMrrc<01><00>eZdZdZy)<03> DBAPITypez<65>protocol representing a :pep:`249` database type.
2025-02-23 09:07:52 +08:00
.. versionadded:: 2.0
.. seealso::
`Type Objects <https://www.python.org/dev/peps/pep-0249/#type-objects>`_
- in :pep:`249`
2025-08-29 00:34:40 +08:00
N)rDrErFrQrLrMrNr<>r<><00>s<00><00> rMr<>c<01><><00>eZdZUdZe dd<02><04>Zedd<04><04>Zded<ded<dd<07>Z d dd <09>Z dd
2025-02-23 09:07:52 +08:00
<EFBFBD>Z
2025-08-29 00:34:40 +08:00
dd <0B>Z ddd <0C>Z dd <0A>Z dd<0E>Zdd<0F>Z d dd<10>Zd d<11>Zd!d<12>Zy)"r<>z<>protocol representing a :pep:`249` database cursor.
2025-02-23 09:07:52 +08:00
.. versionadded:: 2.0
.. seealso::
`Cursor Objects <https://www.python.org/dev/peps/pep-0249/#cursor-objects>`_
- in :pep:`249`
c<01><00>y)z<>The description attribute of the Cursor.
.. seealso::
`cursor.description <https://www.python.org/dev/peps/pep-0249/#description>`_
- in :pep:`249`
2025-08-29 00:34:40 +08:00
NrLrts rN<00> descriptionzDBAPICursor.description<6F>s<00><00> rM<00>intc<01><00>yrZrLrts rN<00>rowcountzDBAPICursor.rowcount<6E>s<00><00>"rM<00> arraysize<7A> lastrowidc<01><00>yrZrLrts rNruzDBAPICursor.close<73>rvrMNc<01><00>yrZrL<00>r\<00> operation<6F>
parameterss rN<00>executezDBAPICursor.execute<74><00><00><00>rMc<01><00>yrZrLr<>s rN<00> executemanyzDBAPICursor.executemany<6E>r<>rMc<01><00>yrZrLrts rN<00>fetchonezDBAPICursor.fetchone<6E><00><00><00>rMc<01><00>yrZrL)r\<00>sizes rN<00> fetchmanyzDBAPICursor.fetchmany<6E><00><00><00>3rMc<01><00>yrZrLrts rN<00>fetchallzDBAPICursor.fetchall<6C>r<>rMc<01><00>yrZrL)r\<00>sizess rN<00> setinputsizeszDBAPICursor.setinputsizes<65>r<>rMc<01><00>yrZrL)r\r<><00>columns rN<00> setoutputsizezDBAPICursor.setoutputsize<7A>s<00><00>SrMc<01><00>yrZrL)r\<00>procnamer<65>s rN<00>callproczDBAPICursor.callproc<6F>s<00><00>rMc<01><00>yrZrLrts rN<00>nextsetzDBAPICursor.nextset<65>r<>rMc<01><00>yrZrLr[s rNr^zDBAPICursor.__getattr__<5F>rorM)ra<00>_DBAPICursorDescription)rar<>r<>rZ)r<>rr<><00>#Optional[_DBAPISingleExecuteParams]rar)r<>rr<><00>_DBAPIMultiExecuteParamsrar)raz Optional[Any]).)r<>r<>ra<00> Sequence[Any])rar<>)r<>r<>rar<>)r<>rr<>rrar<>)r<>r`r<>r<>rar)razOptional[bool]r_)rDrErFrQ<00>propertyr<79>r<><00>__annotations__rur<>r<>r<>r<>r<>r<>r<>r<>r<>r^rLrMrNr<>r<><00>s<><00><00> <08><0E>  <0C> <20>  <0C><0E>  <0C><0E>"<22><0E>"<22><12>N<EFBFBD><12>N<EFBFBD> <20>
2025-02-23 09:07:52 +08:00
;?<3F><12><16><12>8<><12>
<0A> <12> <12><16><12>-<2D><12>
2025-08-29 00:34:40 +08:00
<0A> <12> -<2D>><3E>,<2C>><3E>@<40>:=<3D><12><1B><12>)6<><12> <0C><12>-<2D>/rMr<>r)<06>qmark<72>numeric<69>named<65>format<61>pyformat<61>numeric_dollar<61>TypeEngine[Any])<05> SERIALIZABLEzREPEATABLE READzREAD COMMITTEDzREAD UNCOMMITTED<45>
2025-02-23 09:07:52 +08:00
AUTOCOMMITc<01>r<00>eZdZUded<ded<ded<ded<ded <d
ed <d
ed <d
2025-08-29 00:34:40 +08:00
ed <ded<ded<y)<12>_CoreKnownExecutionOptionszOptional[CompiledCacheType]<5D>compiled_cacher`<00> logging_token<65>IsolationLevel<65>isolation_level<65>bool<6F> no_parameters<72>stream_resultsr<73><00>max_row_buffer<65> yield_per<65>insertmanyvalues_page_sizez Optional[SchemaTranslateMapType]<5D>schema_translate_map<61>preserve_rowcountN)rDrErFr<>rLrMrNr<>r<>s=<00><00>/<2F>/<2F><16><16>#<23>#<23><17><17><18><18><17><17><12>N<EFBFBD> #<23>#<23>:<3A>:<3A><1B>rMr<>F)<01>totalc<01><><00>eZdZUdZded< ded< ded< ded< ded< ded < ded
2025-02-23 09:07:52 +08:00
< ded < ded < d ed< ded<y)<11>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.
2025-08-29 00:34:40 +08:00
r<><00>always<79>on_nullr<6C><00>start<72> increment<6E>minvalue<75>maxvalue<75>
2025-02-23 09:07:52 +08:00
nominvalue<EFBFBD>
2025-08-29 00:34:40 +08:00
nomaxvalue<EFBFBD>cycle<6C> Optional[int]<5D>cache<68>orderN<72>rDrErFrQr<>rLrMrNr<>r<>-sl<00><00><08> <11>L<EFBFBD>!<21> <11>M<EFBFBD><1B> <0E>J<EFBFBD>(<28><12>N<EFBFBD>)<29><11>M<EFBFBD>,<2C><11>M<EFBFBD>,<2C><14><14>+<2B><14><14>+<2B> <0F>K<EFBFBD>%<25> <19><18>1<> <10>K<EFBFBD>-rMr<>c<01>(<00>eZdZUdZded< ded<y)<07>ReflectedComputeda%Represent the reflected elements of a computed column, corresponding
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
r`<00>sqltext<78>NotRequired[bool]<5D> persistedNr<4E>rLrMrNr<>r<>[s<00><00><08><11>L<EFBFBD>"<22>!<21> <20>MrMr<>c<01>|<00>eZdZUdZded< ded< ded< ded < d
2025-02-23 09:07:52 +08:00
ed < d ed < ded< ded< ded<y)<15>ReflectedColumnz<6E>Dictionary representing the reflected elements corresponding to
a :class:`_schema.Column` object.
The :class:`.ReflectedColumn` structure is returned by the
:class:`.Inspector.get_columns` method.
2025-08-29 00:34:40 +08:00
r`<00>namer<65><00>typer<65><00>nullable<6C> Optional[str]<5D>defaultr<74><00> autoincrement<6E>NotRequired[Optional[str]]<5D>commentzNotRequired[ReflectedComputed]<5D>computedzNotRequired[ReflectedIdentity]<5D>identity<74>NotRequired[Dict[str, Any]]<5D>dialect_optionsNr<4E>rLrMrNr<>r<>msj<00><00><08> <0E>I<EFBFBD><15>
2025-02-23 09:07:52 +08:00
<19><19>E<><12>N<EFBFBD>8<> <1A><1A>3<>$<24>$<24>
2025-08-29 00:34:40 +08:00
<08>(<28>'<27><08>-<2D>,<2C><08> -<2D>,<2C><08> 1<>0<>rMr<>c<01>(<00>eZdZUdZded< ded<y)<07>ReflectedConstraintz<74>Dictionary representing the reflected elements corresponding to
2025-02-23 09:07:52 +08:00
:class:`.Constraint`
A base class for all constraints
2025-08-29 00:34:40 +08:00
r<>r<>r<>r<>Nr<4E>rLrMrNr<>r<><00>s<00><00><08> <18><17><19> '<27>'<27>0rMr<>c<01>(<00>eZdZUdZded< ded<y)<07>ReflectedCheckConstraintz<74>Dictionary representing the reflected elements corresponding to
2025-02-23 09:07:52 +08:00
:class:`.CheckConstraint`.
The :class:`.ReflectedCheckConstraint` structure is returned by the
:meth:`.Inspector.get_check_constraints` method.
2025-08-29 00:34:40 +08:00
r`r<>r<>r<>Nr<4E>rLrMrNr<>r<><00>s<00><00><08><11>L<EFBFBD>/<2F>0<>0<>rMr<>c<01>4<00>eZdZUdZded< ded< ded<y) <09>ReflectedUniqueConstraintz<74>Dictionary representing the reflected elements corresponding to
2025-02-23 09:07:52 +08:00
:class:`.UniqueConstraint`.
The :class:`.ReflectedUniqueConstraint` structure is returned by the
:meth:`.Inspector.get_unique_constraints` method.
2025-08-29 00:34:40 +08:00
<20> List[str]<5D> column_namesr<73><00>duplicates_indexr<78>r<>Nr<4E>rLrMrNr<>r<><00>s&<00><00><08><1C><1B>;<3B>0<>0<>L<>0<>0<>rMr<>c<01>(<00>eZdZUdZded< ded<y)<07>ReflectedPrimaryKeyConstraintz<74>Dictionary representing the reflected elements corresponding to
2025-02-23 09:07:52 +08:00
:class:`.PrimaryKeyConstraint`.
The :class:`.ReflectedPrimaryKeyConstraint` structure is returned by the
:meth:`.Inspector.get_pk_constraint` method.
2025-08-29 00:34:40 +08:00
r<><00>constrained_columnsr<73>r<>Nr<4E>rLrMrNr<>r<><00>s<00><00><08>#<23>"<22>5<>0<>0<>KrMr<>c<01>L<00>eZdZUdZded< ded< ded< ded< d ed
2025-02-23 09:07:52 +08:00
<y ) <0C>ReflectedForeignKeyConstraintz<74>Dictionary representing the reflected elements corresponding to
:class:`.ForeignKeyConstraint`.
The :class:`.ReflectedForeignKeyConstraint` structure is returned by
the :meth:`.Inspector.get_foreign_keys` method.
2025-08-29 00:34:40 +08:00
r<>r<>r<><00>referred_schemar`<00>referred_table<6C>referred_columnsr<73><00>optionsNr<4E>rLrMrNr<>r<><00>s6<00><00><08>#<23>"<22>;<3B>"<22>"<22>1<><17><17>*<2A><1F><1F>J<> (<28>(<28>ErMr<>c<01>p<00>eZdZUdZded< ded< ded< ded < d
2025-02-23 09:07:52 +08:00
ed < ded < d ed< ded<y)<12>ReflectedIndexz<78>Dictionary representing the reflected elements corresponding to
:class:`.Index`.
The :class:`.ReflectedIndex` structure is returned by the
:meth:`.Inspector.get_indexes` method.
2025-08-29 00:34:40 +08:00
r<>r<>zList[Optional[str]]r<>zNotRequired[List[str]]<5D> expressionsr<73><00>uniquer<65><00>duplicates_constraint<6E>include_columnsz"NotRequired[Dict[str, Tuple[str]]]<5D>column_sortingr<67>r<>Nr<4E>rLrMrNrrs`<00><00><08> <18><17><14>%<25>%<25><08>
2025-02-23 09:07:52 +08:00
(<28>'<27><08>
2025-08-29 00:34:40 +08:00
<11>L<EFBFBD>4<>5<>5<>A<>+<2B>+<2B><08>7<>6<><08>1<>0<>ErMrc<01><00>eZdZUdZded<y)<05>ReflectedTableCommentz<74>Dictionary representing the reflected comment corresponding to
2025-02-23 09:07:52 +08:00
the :attr:`_schema.Table.comment` attribute.
The :class:`.ReflectedTableComment` structure is returned by the
:meth:`.Inspector.get_table_comment` method.
2025-08-29 00:34:40 +08:00
r<><00>textNr<4E>rLrMrNr r 9s<00><00><08> <18><17>rMr c<01> <00>eZdZdZdZ dZ dZy)<06>
2025-02-23 09:07:52 +08:00
BindTypingz<EFBFBD>Define different methods of passing typing information for
bound parameters in a statement to the database driver.
.. versionadded:: 2.0
2025-08-29 00:34:40 +08:00
r%rrBN)rDrErFrQ<00>NONE<4E> SETINPUTSIZES<45> RENDER_CASTSrLrMrNr r Fs+<00><00><08> <0A>D<EFBFBD><08><16>M<EFBFBD> <08><15>L<EFBFBD>rMr .c<01><>
2025-02-23 09:07:52 +08:00
<00>eZdZUdZej
Zej ZejZejZejZ de
d<de
d< de
d< de
d<de
2025-08-29 00:34:40 +08:00
d < e jd<>d
2025-02-23 09:07:52 +08:00
<EFBFBD><04>Z d e
d < 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
2025-08-29 00:34:40 +08:00
d#< d e
d$< d"e
d%<d&e
d'< d(e
d)< d e
d*< d+e
d,< d-e
d.< d-e
d/< d0e
2025-02-23 09:07:52 +08:00
d1< d e
2025-08-29 00:34:40 +08:00
d2< d e
d3< d e
2025-02-23 09:07:52 +08:00
d4< d e
d5< d e
d6< d e
2025-08-29 00:34:40 +08:00
d7< d8Zde
2025-02-23 09:07:52 +08:00
d9< d e
d:< d e
2025-08-29 00:34:40 +08:00
d;< d e
d<< d e
d=< d e
d>< d e
2025-02-23 09:07:52 +08:00
d?< d e
2025-08-29 00:34:40 +08:00
d@< dAe
dB< d+e
dC< d+e
2025-02-23 09:07:52 +08:00
dD< d e
dE< d e
dF< d e
dG< d e
2025-08-29 00:34:40 +08:00
dH< d e
dI< d e
2025-02-23 09:07:52 +08:00
dJ< d e
dK< d e
2025-08-29 00:34:40 +08:00
dL< d e
dM< dNe
2025-02-23 09:07:52 +08:00
dO< d e
dP< d e
2025-08-29 00:34:40 +08:00
dQ< d+e
dR< d e
dS< d e
dT< d e
dU< d e
dV< d e
dW< dXZdYe
dZ< d[Zd\e
d]< e j"Zd^e
d_< d e
2025-02-23 09:07:52 +08:00
d`< d e
2025-08-29 00:34:40 +08:00
da< d e
db< dcZddZd e
de< d e
df< ej,Z d e
dg< d e
dh< die
dj< d-e
dk< dle
dm< dle
dn< d e
do< d e
dp< d e
dq< d e
dr<dse
dt<d<>du<64>Zd<>dv<64>Zed<>dw<64><04>Zd<>dx<64>Zd<>dy<64>Zerd<>dz<64>Z d<> d<>d{<7B>Z dXdXd|<7C> d<>d}<7D>Z! d<> d<>d~<7E>Z"dXdXd|<7C> d<>d<64>Z# d<> d<>d<EFBFBD><64>Z$dXdXd|<7C> d<>d<EFBFBD><64>Z% d<> d<>d<EFBFBD><64>Z& d<> d<>d<EFBFBD><64>Z' d<> d<>d<EFBFBD><64>Z( d<> d<>d<EFBFBD><64>Z) d<> d<>d<EFBFBD><64>Z* d<> d<>d<EFBFBD><64>Z+d<>d<EFBFBD><64>Z, d<> d<>d<EFBFBD><64>Z- d<> d<>d<EFBFBD><64>Z.dXdXd|<7C> d<>d<EFBFBD><64>Z/ d<> d<>d<EFBFBD><64>Z0dXdXd|<7C> d<>d<EFBFBD><64>Z1 d<> d<>d<EFBFBD><64>Z2dXdXd|<7C> d<>d<EFBFBD><64>Z3 d<> d<>d<EFBFBD><64>Z4dXdXd|<7C> d<>d<EFBFBD><64>Z5 d<> d<>d<EFBFBD><64>Z6dXdXd|<7C> d<>d<EFBFBD><64>Z7d<37>d<EFBFBD><64>Z8d<38>d<EFBFBD><64>Z9 d<> d<>d<EFBFBD><64>Z: d<> d<>d<EFBFBD><64>Z; d<> d<>d<EFBFBD><64>Z< d<>d<EFBFBD><64>Z=d<>d<EFBFBD><64>Z>d<>d<EFBFBD><64>Z?d<>d<EFBFBD><64>Z@d<>d<EFBFBD><64>ZAd<41>d<EFBFBD><64>ZBd<42>d<EFBFBD><64>ZCd<43>d<EFBFBD><64>ZDd<44>d<EFBFBD><64>ZEd<45>d<EFBFBD><64>ZF d<>d<EFBFBD><64>ZGd<47>d<EFBFBD><64>ZHd<48>d<EFBFBD><64>ZI d<>d<EFBFBD><64>ZJd<4A>d<EFBFBD><64>ZKd<4B>d<EFBFBD><64>ZLd<4C>d<EFBFBD><64>ZM d<> d<>d<EFBFBD><64>ZN d<> d<>d<EFBFBD><64>ZOd<4F>d<EFBFBD><64>ZP d<>d<EFBFBD><64>ZQ d<> d<>d<EFBFBD><64>ZR d<> d<>d<EFBFBD><64>ZS d<> d<>d<EFBFBD><64>ZT d<>d<EFBFBD><64>ZUd<55>d<EFBFBD><64>ZVd<56>d<EFBFBD><64>ZWd<57>d<EFBFBD><64>ZXd<58>d<EFBFBD><64>ZY d<>d<EFBFBD><64>ZZ d<>d<EFBFBD><64>Z[d<>d<EFBFBD><64>Z\ d<>d<EFBFBD><64>Z] d<>d<EFBFBD><64>Z^ d<>d<EFBFBD><64>Z_ed<>d<EFBFBD><64><04>Z`ed<>d<EFBFBD><64><04>Zaed<>d<EFBFBD><64><04>Zbe<1A>dd<><64><04>Zc<5A>dd<><64>Zd <00>dd<><64>Ze <00>dd„Zf<5A>dZg<5A>dZhyX(<00>DialectaeDefine the behavior of a specific database and DB-API combination.
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
zdispatcher[Dialect]<5D>dispatchr`r<><00>driver<65>dialect_descriptionzOptional[DBAPIModule]<5D>dbapic<01><00>t<00><00>)zsame as .dbapi, but is never None; will raise an error if no
2025-02-23 09:07:52 +08:00
DBAPI was set up.
.. versionadded:: 2.0
2025-08-29 00:34:40 +08:00
<20><01>NotImplementedErrorrts rN<00> loaded_dbapizDialect.loaded_dbapi<70><00> <00><00>"<22>#<23>#rMr<><00>
2025-02-23 09:07:52 +08:00
positional<EFBFBD>
2025-08-29 00:34:40 +08:00
paramstyler3<00>compiler_lintingzType[SQLCompiler]<5D>statement_compilerzType[DDLCompiler]<5D> ddl_compilerzClassVar[Type[TypeCompiler]]<5D>type_compiler_clsr<00>type_compiler_instancer<00> type_compilerzType[IdentifierPreparer]<5D>preparerr1<00>identifier_preparerzOptional[Tuple[Any, ...]]<5D>server_version_infor<6F><00>default_schema_namezOptional[IsolationLevel]<5D>default_isolation_level<65>skip_autocommit_rollback<63>_on_connect_isolation_levelzType[ExecutionContext]<5D>execution_ctx_clsz4Union[Type[Tuple[Any, ...]], Type[Tuple[List[Any]]]]<5D>execute_sequence_format<61>supports_alterr<72><00>max_identifier_lengthr<68><00>max_index_name_length<74>max_constraint_name_lengthz(Union[generic_fn_descriptor[bool], bool]<5D>supports_server_side_cursors<72>server_side_cursors<72>supports_sane_rowcount<6E>supports_sane_multi_rowcount<6E>supports_empty_insert<72>supports_default_values<65>supports_default_metavalue<75>DEFAULT<4C>default_metavalue_token<65>supports_multivalues_insert<72>insert_executemany_returning<6E>4insert_executemany_returning_sort_by_parameter_order<65>update_executemany_returning<6E>delete_executemany_returning<6E>use_insertmanyvalues<65>!use_insertmanyvalues_wo_returningr2<00>"insertmanyvalues_implicit_sentinelr<6C><00>insertmanyvalues_max_parameters<72>"preexecute_autoincrement_sequences<65>insert_returning<6E>update_returning<6E>update_returning_multifrom<6F>delete_returning<6E>delete_returning_multifrom<6F>favor_returning_over_lastrowid<69>supports_identity_columns<6E>cte_follows_insertz<MutableMapping[Type[TypeEngine[Any]], Type[TypeEngine[Any]]]<5D>colspecs<63>supports_sequences<65>sequences_optional<61>default_sequence_base<73>supports_native_enum<75>supports_native_boolean<61>supports_native_decimal<61>supports_native_uuid<69>returns_native_bytesNzPOptional[List[Tuple[Type[Union[SchemaItem, ClauseElement]], Mapping[str, Any]]]]<5D>construct_argumentsrL<00> Sequence[str]<5D>reflection_optionszMapping[str, str]<5D>dbapi_exception_translation_map<61>supports_comments<74>inline_comments<74>supports_constraint_commentsFT<46>supports_statement_cache<68>_supports_statement_cache<68>is_async<6E> has_terminatezMapping[str, Any]<5D>engine_config_types<65> label_lengthzOptional[Set[Any]]<5D>include_set_input_sizes<65>exclude_set_input_sizes<65>supports_simple_order_by_label<65>div_is_floordiv<69>tuple_in_values<65>_bind_typing_render_castsz.MutableMapping[TypeEngine[Any], _TypeMemoDict]<5D> _type_memosc<01><00>t<00><00>rZrrts rN<00>_builtin_onconnectzDialect._builtin_onconnect<63><00> <00><00>!<21>#<23>#rMc<01><00>t<00><00>)a<>Build DB-API compatible connection arguments.
2025-02-23 09:07:52 +08:00
Given a :class:`.URL` object, returns a tuple
consisting of a ``(*args, **kwargs)`` suitable to send directly
to the dbapi's connect function. The arguments are sent to the
:meth:`.Dialect.connect` method which then runs the DBAPI-level
``connect()`` function.
The method typically makes use of the
:meth:`.URL.translate_connect_args`
method in order to generate a dictionary of options.
The default implementation is::
def create_connect_args(self, url):
opts = url.translate_connect_args()
opts.update(url.query)
return ([], opts)
:param url: a :class:`.URL` object
:return: a tuple of ``(*args, **kwargs)`` which will be passed to the
:meth:`.Dialect.connect` method.
.. seealso::
:meth:`.URL.translate_connect_args`
2025-08-29 00:34:40 +08:00
r<00>r\<00>urls rN<00>create_connect_argszDialect.create_connect_args<67>s <00><00>>"<22>#<23>#rMc<01><00>t<00><00>)a<>Import the DBAPI module that is used by this dialect.
2025-02-23 09:07:52 +08:00
The Python module object returned here will be assigned as an
instance variable to a constructed dialect under the name
``.dbapi``.
.. versionchanged:: 2.0 The :meth:`.Dialect.import_dbapi` class
method is renamed from the previous method ``.Dialect.dbapi()``,
which would be replaced at dialect instantiation time by the
DBAPI module itself, thus using the same name in two different ways.
If a ``.Dialect.dbapi()`` classmethod is present on a third-party
dialect, it will be used and a deprecation warning will be emitted.
2025-08-29 00:34:40 +08:00
r<00><01>clss rN<00> import_dbapizDialect.import_dbapi<70><00> <00><00> "<22>#<23>#rMc<01><00>t<00><00>)a4Transform a generic type to a dialect-specific type.
2025-02-23 09:07:52 +08:00
Dialect classes will usually use the
:func:`_types.adapt_type` function in the types module to
accomplish this.
The returned result is cached *per dialect class* so can
contain no dialect-instance state.
2025-08-29 00:34:40 +08:00
r)r\<00>typeobjs rN<00>type_descriptorzDialect.type_descriptor<00> <00><00>"<22>#<23>#rMc<01><00>y)aCalled during strategized creation of the dialect with a
2025-02-23 09:07:52 +08:00
connection.
Allows dialects to configure options based on server version info or
other properties.
The connection passed here is a SQLAlchemy Connection object,
with full capabilities.
The initialize() method of the base dialect should be called via
super().
.. note:: as of SQLAlchemy 1.4, this method is called **before**
any :meth:`_engine.Dialect.on_connect` hooks are called.
2025-08-29 00:34:40 +08:00
NrL<00>r\<00>
connections rN<00>
initializezDialect.initialize<00><00>rMc<01><00>yrZrL)r\<00> method_names rN<00>_overrides_defaultzDialect._overrides_default(r}rMc <01><00>t<00><00>)a<>Return information about columns in ``table_name``.
2025-02-23 09:07:52 +08:00
Given a :class:`_engine.Connection`, a string
``table_name``, and an optional string ``schema``, return column
information as a list of dictionaries
corresponding to the :class:`.ReflectedColumn` dictionary.
This is an internal dialect method. Applications should use
:meth:`.Inspector.get_columns`.
2025-08-29 00:34:40 +08:00
r<00>r\rz<00>
table_name<EFBFBD>schema<6D>kws rN<00> get_columnszDialect.get_columns*<00> <00><00>&"<22>#<23>#rM)r<><00> filter_namesc <01><00>t<00><00>)a<>Return information about columns in all tables in the
2025-02-23 09:07:52 +08:00
given ``schema``.
This is an internal dialect method. Applications should use
:meth:`.Inspector.get_multi_columns`.
.. 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
2025-08-29 00:34:40 +08:00
r<00>r\rzr<>r<>r<>s rN<00>get_multi_columnszDialect.get_multi_columns?<00> <00><00>4"<22>#<23>#rMc <01><00>t<00><00>)a<>Return information about the primary key constraint on
2025-02-23 09:07:52 +08:00
table_name`.
Given a :class:`_engine.Connection`, a string
``table_name``, and an optional string ``schema``, return primary
key information as a dictionary corresponding to the
:class:`.ReflectedPrimaryKeyConstraint` dictionary.
This is an internal dialect method. Applications should use
:meth:`.Inspector.get_pk_constraint`.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_pk_constraintzDialect.get_pk_constraint[r<>rMc <01><00>t<00><00>)a<>Return information about primary key constraints in
2025-02-23 09:07:52 +08:00
all tables in the given ``schema``.
This is an internal dialect method. Applications should use
:meth:`.Inspector.get_multi_pk_constraint`.
.. 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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_multi_pk_constraintzDialect.get_multi_pk_constraintp<00> <00><00>2"<22>#<23>#rMc <01><00>t<00><00>)a<>Return information about foreign_keys in ``table_name``.
2025-02-23 09:07:52 +08:00
Given a :class:`_engine.Connection`, a string
``table_name``, and an optional string ``schema``, return foreign
key information as a list of dicts corresponding to the
:class:`.ReflectedForeignKeyConstraint` dictionary.
This is an internal dialect method. Applications should use
:meth:`_engine.Inspector.get_foreign_keys`.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_foreign_keyszDialect.get_foreign_keys<79><00> <00><00>$"<22>#<23>#rMc <01><00>t<00><00>)a<>Return information about foreign_keys in all tables
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_multi_foreign_keyszDialect.get_multi_foreign_keys<79>r<>rMc <01><00>t<00><00>)z<>Return a list of table names for ``schema``.
2025-02-23 09:07:52 +08:00
This is an internal dialect method. Applications should use
:meth:`_engine.Inspector.get_table_names`.
2025-08-29 00:34:40 +08:00
r<00>r\rzr<>r<>s rN<00>get_table_nameszDialect.get_table_names<65><00> <00><00>"<22>#<23>#rMc <01><00>t<00><00>)z<>Return a list of temporary table names on the given connection,
2025-02-23 09:07:52 +08:00
if supported by the underlying backend.
This is an internal dialect method. Applications should use
:meth:`_engine.Inspector.get_temp_table_names`.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_temp_table_nameszDialect.get_temp_table_names<65><00> <00><00>"<22>#<23>#rMc <01><00>t<00><00>)aReturn a list of all non-materialized view names available in the
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_view_nameszDialect.get_view_names<65><00> <00><00>"<22>#<23>#rMc <01><00>t<00><00>)aFReturn a list of all materialized view names available in the
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_materialized_view_namesz#Dialect.get_materialized_view_names<65><00> <00><00>"<22>#<23>#rMc <01><00>t<00><00>)a*Return a list of all sequence names available in the database.
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_sequence_nameszDialect.get_sequence_names<65>r<>rMc <01><00>t<00><00>)z<>Return a list of temporary view names on the given connection,
2025-02-23 09:07:52 +08:00
if supported by the underlying backend.
This is an internal dialect method. Applications should use
:meth:`_engine.Inspector.get_temp_view_names`.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_temp_view_nameszDialect.get_temp_view_namesr<>rMc <01><00>t<00><00>)z<>Return a list of all schema names available in the database.
2025-02-23 09:07:52 +08:00
This is an internal dialect method. Applications should use
:meth:`_engine.Inspector.get_schema_names`.
2025-08-29 00:34:40 +08:00
r)r\rzr<>s rN<00>get_schema_nameszDialect.get_schema_names<00> <00><00> "<22>#<23>#rMc <01><00>t<00><00>)aGReturn plain or materialized view definition.
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
r)r\rz<00> view_namer<65>r<>s rN<00>get_view_definitionzDialect.get_view_definition<00> <00><00>""<22>#<23>#rMc <01><00>t<00><00>)a<>Return information about indexes in ``table_name``.
2025-02-23 09:07:52 +08:00
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`.
2025-08-29 00:34:40 +08:00
rr<>s rN<00> get_indexeszDialect.get_indexes+r<>rMc <01><00>t<00><00>)a<>Return information about indexes in in all tables
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_multi_indexeszDialect.get_multi_indexes?r<>rMc <01><00>t<00><00>)a<>Return information about unique constraints in ``table_name``.
2025-02-23 09:07:52 +08:00
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`.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_unique_constraintszDialect.get_unique_constraints[r<>rMc <01><00>t<00><00>)a<>Return information about unique constraints in all tables
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_multi_unique_constraintsz$Dialect.get_multi_unique_constraintsnr<>rMc <01><00>t<00><00>)a<>Return information about check constraints in ``table_name``.
2025-02-23 09:07:52 +08:00
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`.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_check_constraintszDialect.get_check_constraints<74>r<>rMc <01><00>t<00><00>)a<>Return information about check constraints in all tables
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_multi_check_constraintsz#Dialect.get_multi_check_constraints<74>r<>rMc <01><00>t<00><00>)z<>Return a dictionary of options specified when ``table_name``
2025-02-23 09:07:52 +08:00
was created.
This is an internal dialect method. Applications should use
:meth:`_engine.Inspector.get_table_options`.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_table_optionszDialect.get_table_options<6E>r<>rMc <01><00>t<00><00>)a<>Return a dictionary of options specified when the tables in the
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_multi_table_optionszDialect.get_multi_table_options<6E>r<>rMc <01><00>t<00><00>)aReturn the "comment" for the table identified by ``table_name``.
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_table_commentzDialect.get_table_comment<6E>s <00><00>."<22>#<23>#rMc <01><00>t<00><00>)a<>Return information about the table comment in all tables
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_multi_table_commentzDialect.get_multi_table_comment<6E>r<>rMc<01><00>t<00><00>)z<>convert the given name to lowercase if it is detected as
2025-02-23 09:07:52 +08:00
case insensitive.
This method is only used if the dialect defines
requires_name_normalize=True.
2025-08-29 00:34:40 +08:00
r<00>r\r<>s rN<00>normalize_namezDialect.normalize_namerrMc<01><00>t<00><00>)z<>convert the given name to a case insensitive identifier
2025-02-23 09:07:52 +08:00
for the backend if it is an all-lowercase name.
This method is only used if the dialect defines
requires_name_normalize=True.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>denormalize_namezDialect.denormalize_name#rrMc <01><00>t<00><00>)aFor internal dialect use, check the existence of a particular table
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
rr<>s rN<00> has_tablezDialect.has_table-s<00><00>N"<22>#<23>#rMc <01><00>t<00><00>)a<>Check the existence of a particular index name in the database.
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
r)r\rzr<><00>
index_namer<EFBFBD>r<>s rN<00> has_indexzDialect.has_indexVr<>rMc <01><00>t<00><00>)apCheck the existence of a particular sequence in the database.
2025-02-23 09:07:52 +08:00
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`.
2025-08-29 00:34:40 +08:00
r)r\rz<00> sequence_namer<65>r<>s rN<00> has_sequencezDialect.has_sequenceqr<>rMc <01><00>t<00><00>)avCheck the existence of a particular schema name in the database.
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
r)r\rz<00> schema_namer<65>s rN<00>
has_schemazDialect.has_schema<6D>s <00><00>*"<22>#<23>#rMc<01><00>t<00><00>)z<>Retrieve the server version info from the given connection.
2025-02-23 09:07:52 +08:00
This is used by the default implementation to populate the
"server_version_info" attribute and is called exactly
once upon first connect.
2025-08-29 00:34:40 +08:00
rrys rN<00>_get_server_version_infoz Dialect._get_server_version_info<66><00> <00><00>"<22>#<23>#rMc<01><00>t<00><00>)aReturn the string name of the currently selected schema from
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
rrys rN<00>_get_default_schema_namez Dialect._get_default_schema_name<6D>r<>rMc<01><00>t<00><00>)a<>Provide an implementation of ``connection.begin()``, given a
2025-02-23 09:07:52 +08:00
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`.
2025-08-29 00:34:40 +08:00
r<00>r\<00>dbapi_connections rN<00>do_beginzDialect.do_begin<69>r<>rMc<01><00>t<00><00>)z<>Provide an implementation of ``connection.rollback()``, given
2025-02-23 09:07:52 +08:00
a DB-API connection.
:param dbapi_connection: a DBAPI connection, typically
proxied within a :class:`.ConnectionFairy`.
2025-08-29 00:34:40 +08:00
rr<>s rN<00> do_rollbackzDialect.do_rollback<63>r<>rMc<01><00>t<00><00>)z<>Provide an implementation of ``connection.commit()``, given a
2025-02-23 09:07:52 +08:00
DB-API connection.
:param dbapi_connection: a DBAPI connection, typically
proxied within a :class:`.ConnectionFairy`.
2025-08-29 00:34:40 +08:00
rr<>s rN<00> do_commitzDialect.do_commit<69>r<>rMc<01><00>t<00><00>)a<>Provide an implementation of ``connection.close()`` that tries as
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00> do_terminatezDialect.do_terminate<74>r<>rMc<01><00>t<00><00>)a Provide an implementation of ``connection.close()``, given a DBAPI
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>do_closezDialect.do_close<73>r<>rMc<01><00>t<00><00>rZrr<>s rN<00>_do_ping_w_eventzDialect._do_ping_w_event<6E>rjrMc<01><00>t<00><00>)zNping the DBAPI connection and return True if the connection is
usable.rr<>s rN<00>do_pingzDialect.do_ping<6E><00> <00><00>"<22>#<23>#rMc<01><00>t<00><00>)aJinvoke the cursor.setinputsizes() method with appropriate arguments
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
r)r\r|<00>list_of_tuples<65>contexts rN<00>do_set_input_sizeszDialect.do_set_input_sizes<65>r<>rMc<01><00>t<00><00>)z<>Create a two-phase transaction ID.
2025-02-23 09:07:52 +08:00
This id will be passed to do_begin_twophase(),
do_rollback_twophase(), do_commit_twophase(). Its format is
unspecified.
2025-08-29 00:34:40 +08:00
rrts rN<00>
create_xidzDialect.create_xidrrMc<01><00>t<00><00>)z<>Create a savepoint with the given name.
2025-02-23 09:07:52 +08:00
:param connection: a :class:`_engine.Connection`.
:param name: savepoint name.
2025-08-29 00:34:40 +08:00
r<00>r\rzr<>s rN<00> do_savepointzDialect.do_savepoint#rrMc<01><00>t<00><00>)z<>Rollback a connection to the named savepoint.
2025-02-23 09:07:52 +08:00
:param connection: a :class:`_engine.Connection`.
:param name: savepoint name.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>do_rollback_to_savepointz Dialect.do_rollback_to_savepoint-r<>rMc<01><00>t<00><00>)z<>Release the named savepoint on a connection.
2025-02-23 09:07:52 +08:00
:param connection: a :class:`_engine.Connection`.
:param name: savepoint name.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>do_release_savepointzDialect.do_release_savepoint9s <00><00>"<22>#<23>#rMc<01><00>t<00><00>)z<>Begin a two phase transaction on the given connection.
2025-02-23 09:07:52 +08:00
:param connection: a :class:`_engine.Connection`.
:param xid: xid
2025-08-29 00:34:40 +08:00
r<00>r\rz<00>xids rN<00>do_begin_twophasezDialect.do_begin_twophaseBrrMc<01><00>t<00><00>)z<>Prepare a two phase transaction on the given connection.
2025-02-23 09:07:52 +08:00
:param connection: a :class:`_engine.Connection`.
:param xid: xid
2025-08-29 00:34:40 +08:00
rr<>s rN<00>do_prepare_twophasezDialect.do_prepare_twophaseLrrMc<01><00>t<00><00>)a3Rollback a two phase transaction on the given connection.
2025-02-23 09:07:52 +08:00
: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.
2025-08-29 00:34:40 +08:00
r<00>r\rzr<><00> is_prepared<65>recovers rN<00>do_rollback_twophasezDialect.do_rollback_twophaseVr<>rMc<01><00>t<00><00>)a2Commit a two phase transaction on the given connection.
2025-02-23 09:07:52 +08:00
: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.
2025-08-29 00:34:40 +08:00
rr<>s rN<00>do_commit_twophasezDialect.do_commit_twophaseir<>rMc<01><00>t<00><00>)z<>Recover list of uncommitted prepared two phase transaction
2025-02-23 09:07:52 +08:00
identifiers on the given connection.
:param connection: a :class:`_engine.Connection`.
2025-08-29 00:34:40 +08:00
rrys rN<00>do_recover_twophasezDialect.do_recover_twophase}rrMc<01><00>t<00><00>)z<>convert executemany parameters for an INSERT into an iterator
2025-02-23 09:07:52 +08:00
of statement/single execute values, used by the insertmanyvalues
feature.
2025-08-29 00:34:40 +08:00
r)r\rzr|<00> statementr<74><00>generic_setinputsizesr<73>s rN<00>!_deliver_insertmanyvalues_batchesz)Dialect._deliver_insertmanyvalues_batches<65>s <00><00>"<22>#<23>#rMc<01><00>t<00><00>)zSProvide an implementation of ``cursor.executemany(statement,
parameters)``.r<00>r\r|rr<>r<>s rN<00>do_executemanyzDialect.do_executemany<6E>r<>rMc<01><00>t<00><00>)zOProvide an implementation of ``cursor.execute(statement,
parameters)``.rr s rN<00>
do_executezDialect.do_execute<74>r<>rMc<01><00>t<00><00>)z{Provide an implementation of ``cursor.execute(statement)``.
2025-02-23 09:07:52 +08:00
The parameter collection should not be sent.
2025-08-29 00:34:40 +08:00
r)r\r|rr<>s rN<00>do_execute_no_paramszDialect.do_execute_no_params<6D>rwrMc<01><00>t<00><00>)zMReturn True if the given DB-API error indicates an invalid
connectionr)r\<00>erzr|s rN<00> is_disconnectzDialect.is_disconnect<63>r<>rMc<01><00>t<00><00>)a<>Establish a connection using this dialect's DBAPI.
2025-02-23 09:07:52 +08:00
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`
2025-08-29 00:34:40 +08:00
r)r\<00>cargs<67>cparamss rN<00>connectzDialect.connect<63><00><00><00>@"<22>#<23>#rMc<01>"<00>|j<00>S)a& return a callable which sets up a newly created DBAPI connection.
2025-02-23 09:07:52 +08:00
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`
)<01>
2025-08-29 00:34:40 +08:00
on_connectrls rN<00>on_connect_urlzDialect.on_connect_url<72>s<00><00>v<14><EFBFBD><EFBFBD> <20> rMc<01><00>y)a<>return a callable which sets up a newly created DBAPI connection.
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
NrLrts rNrzDialect.on_connect' s<00><00>frMc<01><00>t<00><00>)a2Given a DBAPI connection, revert its isolation to the default.
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>reset_isolation_levelzDialect.reset_isolation_level\ r<>rMc<01><00>t<00><00>)a2Given a DBAPI connection, set its isolation level.
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
r)r\r<><00>levels rN<00>set_isolation_levelzDialect.set_isolation_levelw rrMc<01><00>t<00><00>)a<>Given a DBAPI connection, return its isolation level.
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr<>s rN<00>get_isolation_levelzDialect.get_isolation_level<65> s<00><00>B"<22>#<23>#rMc<01><00>td<01><00>)a<>Detect the current autocommit setting for a DBAPI connection.
:param dbapi_connection: a DBAPI connection object
:return: True if autocommit is enabled, False if disabled
:rtype: bool
This method inspects the given DBAPI connection to determine
whether autocommit mode is currently enabled. The specific
mechanism for detecting autocommit varies by database dialect
and DBAPI driver, however it should be done **without** network
round trips.
.. note::
Not all dialects support autocommit detection. Dialects
that do not support this feature will raise
:exc:`NotImplementedError`.
z;This dialect cannot detect autocommit on a DBAPI connectionr<00>r\<00>
dbapi_conns rN<00>detect_autocommit_settingz!Dialect.detect_autocommit_setting<6E> s<00><00>("<22> I<>
<EFBFBD>
rMc<01><00>t<00><00>)a<>Given a DBAPI connection, return its isolation level, or
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr#s rN<00>get_default_isolation_levelz#Dialect.get_default_isolation_level<65> s <00><00>("<22>#<23>#rMc<01><00>t<00><00>)areturn a sequence of string isolation level names that are accepted
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rr#s rN<00>get_isolation_level_valuesz"Dialect.get_isolation_level_values<65> s<00><00>T"<22>#<23>#rMc<01><00>t<00><00>rZr)r\r$rs rN<00>_assert_and_set_isolation_levelz'Dialect._assert_and_set_isolation_level
r<>rMc<01><00>|S)a}Given a URL, return the :class:`.Dialect` that will be used.
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
rL<00>rqrms rN<00>get_dialect_clszDialect.get_dialect_cls
s <00><00><13>
rMc<01>$<00>|j|<01>S)a<>Given a URL, return the :class:`.Dialect` that will be used by
2025-02-23 09:07:52 +08:00
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`
2025-08-29 00:34:40 +08:00
)r.r-s rN<00>get_async_dialect_clszDialect.get_async_dialect_cls)
s<00><00>"<13>"<22>"<22>3<EFBFBD>'<27>'rMc<01><00>y)aJset up the provision.py module for this dialect.
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
NrLrps rN<00>load_provisioningzDialect.load_provisioning<
r|rMc<01><00>y)a_A convenience hook called before returning the final
2025-02-23 09:07:52 +08:00
: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.
2025-08-29 00:34:40 +08:00
NrL)rq<00>engines rN<00>engine_createdzDialect.engine_createdY
r|rMc<01><00>t<00><00>)a<>Returns the connection object as returned by the external driver
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rrys rN<00>get_driver_connectionzDialect.get_driver_connectionj
r<>rMc<01><00>t<00><00>)aaEstablish execution options for a given engine.
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
r)r\r4<00>optss rN<00>set_engine_execution_optionsz$Dialect.set_engine_execution_optionsy
rwrMc<01><00>t<00><00>)a<>Establish execution options for a given connection.
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
r)r\rzr9s rN<00> set_connection_execution_optionsz(Dialect.set_connection_execution_options<6E>
r<>rMc<01><00>t<00><00>)z*return a Pool class to use for a given URLrrls rN<00>get_dialect_pool_classzDialect.get_dialect_pool_class<73>
s <00><00>!<21>#<23>#rMc<01><00>y)z=Validates an identifier name, raising an exception if invalidNrL)r\<00>idents rN<00>validate_identifierzDialect.validate_identifier<65>
r|rM)rarV)razOptional[_ListenerFnType])rmr)ra<00>ConnectArgsType)ru<00>TypeEngine[_T]rarC)rzr&rar<>)r~r`rar<>rZ)
rzr&r<>r`r<>r<>r<>rrazList[ReflectedColumn])
rzr&r<>r<>r<><00>Optional[Collection[str]]r<>rraz0Iterable[Tuple[TableKey, List[ReflectedColumn]]])
rzr&r<>r`r<>r<>r<>rrar<>)
rzr&r<>r<>r<>rDr<>rraz8Iterable[Tuple[TableKey, ReflectedPrimaryKeyConstraint]])
rzr&r<>r`r<>r<>r<>rraz#List[ReflectedForeignKeyConstraint])
rzr&r<>r<>r<>rDr<>rraz>Iterable[Tuple[TableKey, List[ReflectedForeignKeyConstraint]]])rzr&r<>r<>r<>rrar<>)rzr&r<>rrar<>)
rzr&r<>r`r<>r<>r<>rrar`)
rzr&r<>r`r<>r<>r<>rrazList[ReflectedIndex])
rzr&r<>r<>r<>rDr<>rraz/Iterable[Tuple[TableKey, List[ReflectedIndex]]])
rzr&r<>r`r<>r<>r<>rrazList[ReflectedUniqueConstraint])
rzr&r<>r<>r<>rDr<>rraz:Iterable[Tuple[TableKey, List[ReflectedUniqueConstraint]]])
rzr&r<>r`r<>r<>r<>rrazList[ReflectedCheckConstraint])
rzr&r<>r<>r<>rDr<>rraz9Iterable[Tuple[TableKey, List[ReflectedCheckConstraint]]])
rzr&r<>r`r<>r<>r<>rra<00>Dict[str, Any])
rzr&r<>r<>r<>rDr<>rraz)Iterable[Tuple[TableKey, Dict[str, Any]]])
rzr&r<>r`r<>r<>r<>rrar )
rzr&r<>r<>r<>rDr<>rraz0Iterable[Tuple[TableKey, ReflectedTableComment]])r<>r`rar`)
rzr&r<>r`r<>r<>r<>rrar<>) rzr&r<>r`r<>r`r<>r<>r<>rrar<>)
rzr&r<>r`r<>r<>r<>rrar<>)rzr&r<>r`r<>rrar<>)rzr&rar)rzr&rar`)r<>rrar<>)r<>rrrar<>)r<>rrrar<>)r|r<>r<><00>_GenericSetInputSizesTyper<65><00>ExecutionContextrar<00>rar)rzr&r<>r`rar<>)rzr&r<>rrar<>)TF)
rzr&r<>rr<>r<>r<>r<>rar<>)rzr&raz List[Any])rzr&r|r<>rr`r<>r<>rz#Optional[_GenericSetInputSizesType]r<>rGraz Iterator[_InsertManyValuesBatch])
r|r<>rr`r<>r<>r<><00>Optional[ExecutionContext]rar<>)
r|r<>rr`r<>r<>r<>rIrar<>)r|r<>rr`r<>rIrar<>)rrXrzz7Optional[Union[PoolProxiedConnection, DBAPIConnection]]r|<00>Optional[DBAPICursor]rar<>)rrrrrarr)rmr)razOptional[Callable[[Any], Any]])razOptional[Callable[[Any], None]])r<>rrrr<>rar<>)r<>rrrar<>)r$rrrar<>)r$rrrar<>)r$rrrazSequence[IsolationLevel])r$rrrr<>rar<>)rmr)ra<00> Type[Dialect]r<><00>r4r'rar<>)rzrrrar)r4r'r9<00>CoreExecuteOptionsParameterrar<>)rzr&r9rMrar<>)rmr)ra<00>
Type[Pool])r@r`rar<>)irDrErFrQrArGrHrIrJrKr<>r<00>non_memoized_propertyrr8rTrV<00>
EMPTY_DICTrW<00> _has_eventsr[r r <00> bind_typingrirn<00> classmethodrrrvr{rrr<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>rrrr
r rrrrrrrr!r%r'r)r+r.r0r2r5r7r:r<r>rArLrMrNrr<00>s<> <00><00> <08><1B>$<24>$<24>I<EFBFBD><1B>&<26>&<26>J<EFBFBD>!<21>2<>2<><14><1D>*<2A>*<2A>L<EFBFBD>#<23>6<>6<><16>!<21>!<21>
<0A>I<EFBFBD><08> <10>K<EFBFBD>2<><1C><1C> <20> <20><08>,
2025-02-23 09:07:52 +08:00
<EFBFBD><1F><1F>$<24> <20>$<24><15><14>@<40><13>O<EFBFBD><08><1E><1D>)<29>)<29>C<>#<23>#<23>C<>3<>3<><08> )<29>(<28><08><17><16><08>'<27>&<26><08>,<2C>+<2B><08>
2025-08-29 00:34:40 +08:00
3<>2<><08> '<27>&<26><08>6<>5<>E<>"<22>"<22><08>":<3A>9<>-<2D>-<2D>O<><06><06>4<><19><18><08><1F><1E>1<>(<28>(<28>"<22> -<2D>-<2D>"<22>#K<01>J<>?<3F><1D><1D><1F>!<21> <20><08>#'<27>&<26><08>
2025-02-23 09:07:52 +08:00
 <20><1F><08>"<22>!<21>:<3A> $<24>$<24><08>$-<2D><1B>S<EFBFBD>,<2C><08>"&<26>%<25><08>
#'<27>&<26><08>
;?<3F>><3E><08>#'<27>&<26>><3E>"&<26>&<26>><3E><1E><1E><08><(,<2C>+<2B> <08>)E<01>D<>
<08>!$<24>#<23> <08>&)<29>(<28><08> )-<2D>,<2C><08><1B><1A><08> <1B><1A><08> !%<25>$<24><08> <1B><1A><08> !%<25>$<24><08> %)<29>(<28><08> $<24>#<23>+<2B><1C><1C>&<26>K<01>J<><08> <1D><1C>G<><1C><1C><08><1F><1E><08>
<1F><1E><08>
"<22>!<21><08>
"<22>!<21>0<><1F><1E><08><1F><1E><08> <0A><18><06> <0A><08><)+<2B><16> <0A>*<2A><08>:><3E><1F><1F>#<23>%6<>H<><08><1C><1B>K<><19><19>1<>#'<27>&<26><08>
<18>K<EFBFBD>%)<29><1C>d<EFBFBD>)<29><08>" $<24>#<23>:<3A><1C>/<2F>/<2F>K<EFBFBD><08><13>N<EFBFBD>B<><17><17>0<>+<2B>*<2A><08>
2025-08-29 00:34:40 +08:00
 <20><1F>9<>/<2F>/<2F><08>0<>/<2F><08>%)<29>(<28>=<3D><1A><19>M<><19><19>L<>#<23>#<23>?<3F>?<3F>$<24>$<24>B<11>$<24><11>$<24>" $<24> <0C>$<15>C<> !%<25> $<24><1E>$<24><18>$<24><1E> $<24>
2025-02-23 09:07:52 +08:00
<12> $<24>
<1F> $<24>2!%<25>26<32> $<24><1E>$<24><1E> $<24>
0<> $<24> <12> $<24>
:<3A>$<24>@!%<25> $<24><1E>$<24><18>$<24><1E> $<24>
<12> $<24>
'<27> $<24>2!%<25>26<32> $<24><1E>$<24><1E> $<24>
0<> $<24> <12> $<24>
B<01>$<24>>!%<25> $<24><1E>$<24><18>$<24><1E> $<24>
<12> $<24>
-<2D> $<24>0!%<25>26<32> $<24><1E>$<24><1E> $<24>
0<> $<24> <12> $<24>
H<01>$<24>:?C<01>
$<24>$<24>
$<24>.;<3B>
$<24>JM<4A>
$<24> <12>
$<24>?C<01> $<24>$<24> $<24>.;<3B> $<24>JM<4A> $<24> <12> $<24>?C<01> $<24>$<24> $<24>.;<3B> $<24>JM<4A> $<24> <12> $<24> ?C<01>$<24>$<24>$<24>.;<3B>$<24>JM<4A>$<24> <12>$<24>$?C<01> $<24>$<24> $<24>.;<3B> $<24>JM<4A> $<24> <12> $<24> ?C<01> $<24>$<24> $<24>.;<3B> $<24>JM<4A> $<24> <12> $<24>$<24>!%<25> $<24><1E>$<24><17>$<24><1E> $<24>
<12> $<24>
<0A> $<24>.!%<25> $<24><1E>$<24><18>$<24><1E> $<24>
<12> $<24>
<1E> $<24>0!%<25>26<32> $<24><1E>$<24><1E> $<24>
0<> $<24> <12> $<24>
9<EFBFBD>$<24>@!%<25> $<24><1E>$<24><18>$<24><1E> $<24>
<12> $<24>
)<29> $<24>.!%<25>26<32> $<24><1E>$<24><1E> $<24>
0<> $<24> <12> $<24>
D<01>$<24>@!%<25> $<24><1E>$<24><18>$<24><1E> $<24>
<12> $<24>
(<28> $<24>0!%<25>26<32> $<24><1E>$<24><1E> $<24>
0<> $<24> <12> $<24>
C<01>$<24>@!%<25> $<24><1E> $<24><18> $<24><1E> $<24>
<12> $<24>
<18> $<24>&!%<25>26<32> $<24><1E>$<24><1E> $<24>
0<> $<24> <12> $<24>
3<EFBFBD>$<24>>!%<25> $<24><1E>$<24><18>$<24><1E> $<24>
<12> $<24>
<1F> $<24>:!%<25>26<32> $<24><1E>$<24><1E> $<24>
0<> $<24> <12> $<24>
:<3A>$<24>8$<24>$<24>!%<25> '$<24><1E>'$<24><18>'$<24><1E> '$<24>
<12> '$<24>
<0E> '$<24>\!%<25> $<24><1E>$<24><18>$<24><18> $<24>
<1E> $<24> <12> $<24>
<0E>$<24>>!%<25> $<24><1E>$<24><1B>$<24><1E> $<24>
<12> $<24>
<0E> $<24>&$<24>$<24>$<24>36<33>$<24>>A<>$<24> <0A>$<24>. $<24>
$<24> $<24> $<24> $<24>$<24>" $<24>$<24>$<24>
$<24><1B>$<24>2<>$<24>"<22> $<24>
<0A> $<24>8$<24>$<24>
$<24>$<24>
$<24>,/<2F>
$<24> <0A>
$<24>$<24>$<24>$<24>!<21><1D> $<24><1E>$<24><11>$<24><1A> $<24>
<16> $<24>
<0E> $<24>.!<21><1D> $<24><1E>$<24><11>$<24><1A> $<24>
<16> $<24>
<0E> $<24>($<24>$<24><1E>$<24><1C>$<24><17> $<24>
-<2D> $<24> C<01> $<24>"<22>$<24>
*<2A>$<24>*/3<>
$<24><1B>
$<24><17>
$<24>-<2D>
$<24>
,<2C>
$<24>
<0E>
$<24>"/3<>
$<24><1B>
$<24><17>
$<24>8<>
$<24>
,<2C>
$<24>
<0E>
$<24> /3<> $<24><1B> $<24><17> $<24>,<2C> $<24>
2025-08-29 00:34:40 +08:00
<0E> $<24> $<24> <1C> $<24>L<01> $<24>&<26> $<24>
2025-02-23 09:07:52 +08:00
2025-08-29 00:34:40 +08:00
<0E> $<24> $<24>D;!<21>z3<14>j$<24>6 $<24> /<2F> $<24>8F<38> $<24> <0A> $<24>D!$<24> /<2F>!$<24> <17>!$<24>F
<EFBFBD>0$<24>)<29>$<24> <17>$<24>,*$<24>)<29>*$<24> !<21>*$<24>X$<24>)<29>$<24>2@<40>$<24> <0A>$<24>
<11> <13><11> <13><11>(<28><11>(<28>$<11> <0C><11> <0C>8<11> <0C><11> <0C> $<24> $<24><1C> $<24>$?<3F> $<24> <0A> $<24> $<24>$<24> $<24>,G<> $<24> <0A> $<24>$<24>LrMrc<01>P<00>eZdZdZdd<02>Zd d<03>Z d
2025-02-23 09:07:52 +08:00
d<04>Z d d<05>Zd d<06>Zy) <0A>CreateEnginePlugina<6E>A 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`).
c<01><00>||_y)a<>Construct 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`.
2025-08-29 00:34:40 +08:00
N)rm)r\rmr{s rN<00>__init__zCreateEnginePlugin.__init__N s <00><00>2<17><04>rMc<01><00>t<00><00>)aUpdate the :class:`_engine.URL`.
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
rrls rN<00>
update_urlzCreateEnginePlugin.update_urli r<>rMc<01><00>y)zparse and modify dialect kwargsNrL)r\<00> dialect_cls<6C> dialect_argss rN<00>handle_dialect_kwargsz(CreateEnginePlugin.handle_dialect_kwargsz r|rMc<01><00>y)zparse and modify pool kwargsNrL)r\<00>pool_cls<6C> pool_argss rN<00>handle_pool_kwargsz%CreateEnginePlugin.handle_pool_kwargs r|rMc<01><00>y)z<>Receive the :class:`_engine.Engine`
2025-02-23 09:07:52 +08:00
object when it is fully constructed.
The plugin may make additional changes to the engine, such as
registering engine or connection pool events.
2025-08-29 00:34:40 +08:00
NrL)r\r4s rNr5z!CreateEnginePlugin.engine_created<65> r|rMN)rmr)r{rE)rmr)rar))r[rKr\rErar<>)r_rNr`rErar<>rL) rDrErFrQrWrYr]rar5rLrMrNrUrU<00>
2025-02-23 09:07:52 +08:00
sR<00><00>m<08>^<17>6$<24>".<2E>(<28>.<2E>8F<38>.<2E> <0A>.<2E>
+<2B>"<22>+<2B>/=<3D>+<2B> <0A>+<2B>
2025-08-29 00:34:40 +08:00
 rMrUc<01>0<00>eZdZUdZded< ded< ded< ded< d ed
2025-02-23 09:07:52 +08:00
< d ed < d ed< ded< ded< ded< ded< ded< ded< ded< ded< ded< ded< e d1d<1F><04>Zeejf d2d <20><05>Z e d3d!<21><04>Z
2025-08-29 00:34:40 +08:00
e d4d"<22><04>Z d5d#<23>Z d6d$<24>Z d7d%<25>Zd8d&<26>Zd9d'<27>Zd:d(<28>Zd;d)<29>Z d<d*<2A>Zd;d+<2B>Zd=d,<2C>Zd>d-<2D>Zd?d.<2E>Zd@d/<2F>Zy0)ArGzRA messenger object for a Dialect that corresponds to a single
2025-02-23 09:07:52 +08:00
execution.
2025-08-29 00:34:40 +08:00
r'r4r&rz<00>root_connectionr<00>dialectr<74>r|zOptional[Compiled]<5D>compiledr`rzOptional[Executable]<5D>invoked_statement<6E>_AnyMultiExecuteParamsr<73>r<>r<><00>isinsert<72>isupdaterP<00> execute_styler<65>z;util.generic_fn_descriptor[Optional[Sequence[Column[Any]]]]<5D> prefetch_cols<6C>postfetch_cols<6C>_ExecuteOptions<6E>execution_optionsc<01><00>t<00><00>rZr)rqrerzr<>ro<00> compiled_ddls rN<00> _init_ddlzExecutionContext._init_ddl<64> r<>rMc
<01><00>t<00><00>rZr)
rqrerzr<>rorfr<>rg<00>extracted_parameters<72> cache_hits
rN<00>_init_compiledzExecutionContext._init_compiled<65> r<>rMc<01><00>t<00><00>rZr)rqrerzr<>rorr<>s rN<00>_init_statementz ExecutionContext._init_statement r<>rMc<01><00>t<00><00>rZr)rqrerzr<>ros rN<00> _init_defaultzExecutionContext._init_default rrMc<01><00>t<00><00>rZr)r\r<>r<><00>type_s rN<00> _exec_defaultzExecutionContext._exec_default r<>rMc<01><00>t<00><00>rZrrts rN<00>_prepare_set_input_sizesz)ExecutionContext._prepare_set_input_sizes" r<>rMc<01><00>t<00><00>rZrrts rN<00>_get_cache_statsz!ExecutionContext._get_cache_stats' rjrMc<01><00>t<00><00>rZrrts rN<00>_setup_result_proxyz$ExecutionContext._setup_result_proxy* rjrMc<01><00>t<00><00>)zKgiven a :class:`.Sequence`, invoke it and return the next int
valuer)r\<00>seqr|s rN<00> fire_sequencezExecutionContext.fire_sequence- r<>rMc<01><00>t<00><00>)z<>Return a new cursor generated from this ExecutionContext's
2025-02-23 09:07:52 +08:00
connection.
Some dialects may wish to change the behavior of
connection.cursor(), such as postgresql which may return a PG
"server side" cursor.
2025-08-29 00:34:40 +08:00
rrts rN<00> create_cursorzExecutionContext.create_cursor2 r<>rMc<01><00>t<00><00>)z<>Called before an execution of a compiled statement.
2025-02-23 09:07:52 +08:00
If a compiled statement was passed to this ExecutionContext,
the `statement` and `parameters` datamembers must be
initialized after this statement is complete.
2025-08-29 00:34:40 +08:00
rrts rN<00>pre_execzExecutionContext.pre_exec= rrMc<01><00>t<00><00>)a!Return a sequence of OUT parameter values from a cursor.
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
r)r\<00>out_param_namess rN<00>get_out_parameter_valuesz)ExecutionContext.get_out_parameter_valuesG s<00><00>D"<22>#<23>#rMc<01><00>t<00><00>)aCalled after the execution of a compiled statement.
2025-02-23 09:07:52 +08:00
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.
2025-08-29 00:34:40 +08:00
rrts rN<00> post_execzExecutionContext.post_execk rrMc<01><00>t<00><00>)zQReceive a DBAPI exception which occurred upon execute, result
fetch, etc.r)r\rs rN<00>handle_dbapi_exceptionz'ExecutionContext.handle_dbapi_exceptionu s <00><00>"<22>#<23>#rMc<01><00>t<00><00>)zjReturn True if the last INSERT or UPDATE row contained
2025-02-23 09:07:52 +08:00
inlined or database-side defaults.
2025-08-29 00:34:40 +08:00
rrts rN<00>lastrow_has_defaultsz%ExecutionContext.lastrow_has_defaults{ s <00><00>
"<22>#<23>#rMc<01><00>t<00><00>)z<>Return the DBAPI ``cursor.rowcount`` value, or in some
2025-02-23 09:07:52 +08:00
cases an interpreted value.
See :attr:`_engine.CursorResult.rowcount` for details on this.
2025-08-29 00:34:40 +08:00
rrts rN<00> get_rowcountzExecutionContext.get_rowcount<6E> rrMc<01><00>t<00><00>)aFor a RETURNING result, deliver cursor.fetchall() from the
2025-02-23 09:07:52 +08:00
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
2025-08-29 00:34:40 +08:00
r)r\r|s rN<00>fetchall_for_returningz'ExecutionContext.fetchall_for_returning<6E> rsrMN) rerrzr&r<>rrornrqr0rarG)rerrzr&r<>rrornrfr4r<><00>_CoreMultiExecuteParamsrgr.rtz&Optional[Sequence[BindParameter[Any]]]rurArarG)rerrzr&r<>rrornrr`r<>r<>rarG)
rerrzr&r<>rrornrarG)r<>zOptional[Column[Any]]r<>r8r|zOptional[TypeEngine[Any]]rar)raz0Optional[List[Tuple[str, Any, TypeEngine[Any]]]]<5D>rar`)razCursorResult[Any])r<><00>Sequence_SchemaItemr|r:rar<>)rar<>r<>)r<>rUrar<>)r<00> BaseExceptionrar<>)rar<>)rar<>)r|r<>rar<>)rDrErFrQr<>rSrrrArIrvrxrzr}rr<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>rLrMrNrGrG<00> s<><00><00><08>
2025-02-23 09:07:52 +08:00
<13>N<EFBFBD>8<><1A><1A><1A>
 <20><1F>I<> <14><14>6<> <17><17>4<> <20> <20><18><13>N<EFBFBD>C<01>,<2C>+<2B><08>'<27>&<26><08><18><17>=<3D><12>N<EFBFBD>-<2D><12>N<EFBFBD>-<2D><1F><1F><08><16><15><08>O<01>N<>9<>P<01>O<><16>'<27>&<26>K<><10>$<24><18>$<24><1F>$<24>0<> $<24>
+<2B> $<24> "<22> $<24>
<1A>$<24><11>$<24><11>!+<2B> ;<3B> ;<3B> $<24><18> $<24><1F> $<24>0<> $<24>
+<2B> $<24> <1E> $<24>,<2C> $<24>&<26> $<24>E<01> $<24><1E> $<24>
<1A> $<24><11> $<24><11> $<24><18> $<24><1F> $<24>0<> $<24>
+<2B> $<24> <17> $<24>-<2D> $<24>
<1A> $<24><11> $<24><11>$<24><18>$<24><1F>$<24>0<> $<24>
+<2B> $<24>
<1A> $<24><11>$<24>$<24>%<25>$<24>"<22>$<24>)<29> $<24>
<0A> $<24>$<24> 9<>$<24>
$<24>$<24>$<24>
2025-08-29 00:34:40 +08:00
$<24>$<24>"$<24>,<2C>"$<24> <16>"$<24>H$<24>$<24> $<24>$<24>$rMrGc<01><00>eZdZUdZded<y)<05>ConnectionEventsTargetz<74>An object which can accept events from :class:`.ConnectionEvents`.
2025-02-23 09:07:52 +08:00
Includes :class:`_engine.Connection` and :class:`_engine.Engine`.
.. versionadded:: 2.0
2025-08-29 00:34:40 +08:00
z"dispatcher[ConnectionEventsTarget]rNr<4E>rLrMrNr<>r<><00> s<00><00><08>1<>0rMr<>c<01><><00>eZdZUdZdZded< ded< ded< d ed
2025-02-23 09:07:52 +08:00
< d ed < d ed< ded< ded< ded< ded< ded< ded< ded<y)<1C>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.
2025-08-29 00:34:40 +08:00
rLrrezOptional[Connection]rzzOptional[Engine]r4rJr|r<>rz Optional[_DBAPIAnyExecuteParams]r<>r<><00>original_exceptionzOptional[StatementError]<5D>sqlalchemy_exceptionzOptional[BaseException]<5D>chained_exceptionrI<00>execution_contextr<74>r<00>invalidate_pool_on_disconnect<63> is_pre_pingN)rDrErFrQ<00> __slots__r<5F>rLrMrNr<>r<><00> s<><00><00><08><13>I<EFBFBD> <14><14><08>%<25>$<24>
<08> <1D><1C><08> "<22>!<21><08> <1D><1C><08> 1<>0<><08> &<26>%<25><08> 3<>2<><08>/<2F>.<2E><08>2<>1<><08>&<18><17><08>0$(<28>'<27><08> <16><15>rMr<>c<01>B<00>eZdZUdZdZded<ed d<05><04>Zd
2025-02-23 09:07:52 +08:00
d<06>Zd d<07>Z y) <0C>AdaptedConnectionz<6E>Interface 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
2025-08-29 00:34:40 +08:00
<20><01> _connectionr*r<>c<01><00>|jS)z@The connection object as returned by the driver after a connect.r<>rts rN<00>driver_connectionz#AdaptedConnection.driver_connectionb s<00><00><14><1F><1F>rMc<01>8<00>t||j<00><00>S)aARun the awaitable returned by the given function, which is passed
2025-02-23 09:07:52 +08:00
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`
2025-08-29 00:34:40 +08:00
)r r<>)r\<00>fns rN<00> run_asynczAdaptedConnection.run_asyncg s<00><00><<1A>"<22>T<EFBFBD>-<2D>-<2D>.<2E>/<2F>/rMc<01> <00>d|jzS)Nz<AdaptedConnection %s>r<>rts rN<00>__repr__zAdaptedConnection.__repr__<5F> s<00><00>'<27>$<24>*:<3A>*:<3A>:<3A>:rMNrH)r<>zCallable[[Any], Awaitable[_T]]rar>r<>)
rDrErFrQr<>r<>r<>r<>r<>r<>rLrMrNr<>r<>T s1<00><00><08>!<21>I<EFBFBD>'<27>'<27> <0A> <20><0E> <20>0<>@;rMr<>N)<29>rQ<00>
__future__r<00>enumr<00>typingrrrrr r
r r r rrrrrrrrrr<00>r<00>eventr<00>poolrr<00> sql.compilerrrr<00>util.concurrencyr <00> util.typingr!r"r#r$<00>baser&r'r|r(rmr)<00>connectors.asyncior*r+r,<00>excr-<00>sqlr.r/r0r1r2r3r4<00> sql.elementsr5r6<00>
sql.schemar7r8r9r<><00> sql.sqltypesr:<00> sql.type_apir;r<<00>util.langhelpersr=r`rBr>rArPrVrrr<>r<><00>_CoreSingleExecuteParams<6D>_MutableCoreSingleExecuteParamsr<73><00>_CoreAnyExecuteParams<6D>_DBAPISingleExecuteParamsr<73><00>_DBAPIAnyExecuteParamsr<73>r<>r<><00>_AnySingleExecuteParamsrh<00>_AnyExecuteParams<6D>CompiledCacheType<70>SchemaTranslateMapType<70>_ImmutableExecuteOptions<6E> _ParamStylerFr<>r<>rnrMr<>r<>r<>r<>r<>r<>r<>r<>rr r <00>VersionInfoType<70>TableKeyrrUrGr<><00> Connectabler<65>r<>rLrMrN<00><module>r<>s<><00><01>8<>"<22><15><16><1C><1B><1B><1D><17><1B><1B><17><1A>!<21><1B><1B><16><18><17> <20><1A><18><13><1F><17>A<>/<2F>#<23>7<>'<27> <20>)<29>!<21>%<25>"<22>#<23><10> <20><1C>$<24><18>;<3B>'<27>"<22>$<24> <20>5<>*<2A>1<>;<3B>&<26>*<2A>,<2C>,<2C>#<23>-<2D>'<27><<3C>&<26>,<2C>)<29>8<><17><08><13> <0A>~<7E>c<EFBFBD>3<EFBFBD>h<EFBFBD>'?<3F>?<3F>@<40><0F> <0C>T<EFBFBD><15><1F><02><1B><14><1B><08>4<EFBFBD><08>, 0<>(<28> 0<> =<3D>h<EFBFBD>=<3D>2
2025-02-23 09:07:52 +08:00
<08><08>
<08>@0<>(<28>@0<>F#<23>3<EFBFBD><03>8<EFBFBD>,<2C><18>"0<><13>c<EFBFBD><18>":<3A><1F>"<22>#;<3B><<3C><17><1D><1B>5<>5<><02><15>"<22>(<28>3<EFBFBD>-<2D>1I<31>"I<>J<><19> <20> <0C>X<EFBFBD>c<EFBFBD>]<5D><1B>4<>4<><02><18><1F><1C>7<>7<><02><16>#<23> <09> <0B><13><10><13> <0A><10><13> <0A><10><13> <0A><10><13> <0A><10><14><0E>  <18><06>
<02><17>4<><17>1<><16>*<2A><11>"<22>3<EFBFBD>
<EFBFBD>?<3F>3<><11> <20><18>#<23><1D><08><13> <0A>!=<3D>><3E><16>(<28><13>c<EFBFBD><18>2<><18><15>G<><02> <0B>!<21><15>s<EFBFBD>C<EFBFBD>1B<31>'B<>!C<>D<><19><18><12><02><0E>
<1C><19>%<25>
<1C> <20><03>S<EFBFBD><08>)<29><0F>#<23><1E><07><03>S<EFBFBD><08> 1<>1<><02><1B>
+.<2E> <09>+.<2E>\N<01> <09>N<01>$7<0E>i<EFBFBD>7<0E>t 1<>)<29> 1<><08>2<><08>&<12> 3<><12>( L<01>$7<> L<01> F<01>$7<>F<01>21F<01>Y<EFBFBD>1F<01>h
<1E>I<EFBFBD>
2025-08-29 00:34:40 +08:00
<1E>9<08><14>9<08>x<18><05>c<EFBFBD>3<EFBFBD>h<EFBFBD><0F><13>,<2C>-<2D><0F> <10><18>#<23><1D><03>#<23> $<24><08>U L<01>k<EFBFBD>U L<01>p@m <0C>m <0C>`N$<24>N$<24>b 1<>[<5B> 1<>%<25> <0B>c<08>c<08>L4;<3B>4;rM