Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les compléments
Voir le programme détaillé
Module « sqlalchemy »

Classe « Connection »

Informations générales

Héritage

builtins.object
    Generic
        Inspectable
builtins.object
    EventTarget
        ConnectionEventsTarget
            Connection

Définition

class Connection(ConnectionEventsTarget, Inspectable):

help(Connection)

Provides high-level functionality for a wrapped DB-API connection.

The :class:`_engine.Connection` object is procured by calling the
:meth:`_engine.Engine.connect` method of the :class:`_engine.Engine`
object, and provides services for execution of SQL statements as well
as transaction control.

The Connection object is **not** thread-safe. While a Connection can be
shared among threads using properly synchronized access, it is still
possible that the underlying DBAPI connection may not support shared
access between threads. Check the DBAPI documentation for details.

The Connection object represents a single DBAPI connection checked out
from the connection pool. In this state, the connection pool has no
affect upon the connection, including its expiration or timeout state.
For the connection pool to properly manage connections, connections
should be returned to the connection pool (i.e. ``connection.close()``)
whenever the connection is not in use.

.. index::
  single: thread safety; Connection

Constructeur(s)

Signature du constructeur Description
__init__(self, engine: 'Engine', connection: 'Optional[PoolProxiedConnection]' = None, _has_events: 'Optional[bool]' = None, _allow_revalidate: 'bool' = True, _allow_autobegin: 'bool' = True) Construct a new Connection. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
dispatch<sqlalchemy.event.base.ConnectionEventsDispatch object at 0x0000020D9F3A8910>
should_close_with_resultFalse

Liste des propriétés

Nom de la propriétéDescription
closedReturn True if this connection is closed. [extrait de closed.__doc__]
connectionThe underlying DB-API connection managed by this Connection. [extrait de connection.__doc__]
default_isolation_levelThe initial-connection time isolation level associated with the [extrait de default_isolation_level.__doc__]
infoInfo dictionary associated with the underlying DBAPI connection [extrait de info.__doc__]
invalidatedReturn True if this connection was invalidated. [extrait de invalidated.__doc__]

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__class_getitem__ Parameterizes a generic class. [extrait de __class_getitem__.__doc__]
__enter__(self) -> 'Connection'
__exit__(self, type_: 'Any', value: 'Any', traceback: 'Any') -> 'None'
begin(self) -> 'RootTransaction' Begin a transaction prior to autobegin occurring. [extrait de begin.__doc__]
begin_nested(self) -> 'NestedTransaction' Begin a nested transaction (i.e. SAVEPOINT) and return a transaction [extrait de begin_nested.__doc__]
begin_twophase(self, xid: 'Optional[Any]' = None) -> 'TwoPhaseTransaction' Begin a two-phase or XA transaction and return a transaction [extrait de begin_twophase.__doc__]
close(self) -> 'None' Close this :class:`_engine.Connection`. [extrait de close.__doc__]
commit(self) -> 'None' Commit the transaction that is currently in progress. [extrait de commit.__doc__]
commit_prepared(self, xid: 'Any', recover: 'bool' = False) -> 'None'
detach(self) -> 'None' Detach the underlying DB-API connection from its connection pool. [extrait de detach.__doc__]
exec_driver_sql(self, statement: 'str', parameters: 'Optional[_DBAPIAnyExecuteParams]' = None, execution_options: 'Optional[CoreExecuteOptionsParameter]' = None) -> 'CursorResult[Any]' Executes a string SQL statement on the DBAPI cursor directly, [extrait de exec_driver_sql.__doc__]
execute(self, statement: 'Executable', parameters: 'Optional[_CoreAnyExecuteParams]' = None, *, execution_options: 'Optional[CoreExecuteOptionsParameter]' = None) -> 'CursorResult[Any]' Executes a SQL statement construct and returns a [extrait de execute.__doc__]
execution_options(self, **opt: 'Any') -> 'Connection' Set non-SQL options for the connection which take effect [extrait de execution_options.__doc__]
get_execution_options(self) -> '_ExecuteOptions' Get the non-SQL options which will take effect during execution. [extrait de get_execution_options.__doc__]
get_isolation_level(self) -> 'IsolationLevel' Return the current **actual** isolation level that's present on [extrait de get_isolation_level.__doc__]
get_nested_transaction(self) -> 'Optional[NestedTransaction]' Return the current nested transaction in progress, if any. [extrait de get_nested_transaction.__doc__]
get_transaction(self) -> 'Optional[RootTransaction]' Return the current root transaction in progress, if any. [extrait de get_transaction.__doc__]
in_nested_transaction(self) -> 'bool' Return True if a transaction is in progress. [extrait de in_nested_transaction.__doc__]
in_transaction(self) -> 'bool' Return True if a transaction is in progress. [extrait de in_transaction.__doc__]
invalidate(self, exception: 'Optional[BaseException]' = None) -> 'None' Invalidate the underlying DBAPI connection associated with [extrait de invalidate.__doc__]
recover_twophase(self) -> 'List[Any]'
rollback(self) -> 'None' Roll back the transaction that is currently in progress. [extrait de rollback.__doc__]
rollback_prepared(self, xid: 'Any', recover: 'bool' = False) -> 'None'
scalar(self, statement: 'Executable', parameters: 'Optional[_CoreSingleExecuteParams]' = None, *, execution_options: 'Optional[CoreExecuteOptionsParameter]' = None) -> 'Any' Executes a SQL statement construct and returns a scalar object. [extrait de scalar.__doc__]
scalars(self, statement: 'Executable', parameters: 'Optional[_CoreAnyExecuteParams]' = None, *, execution_options: 'Optional[CoreExecuteOptionsParameter]' = None) -> 'ScalarResult[Any]' Executes and returns a scalar result set, which yields scalar values [extrait de scalars.__doc__]
schema_for_object(self, obj: 'HasSchemaAttr') -> 'Optional[str]' Return the schema name for the given schema item taking into [extrait de schema_for_object.__doc__]

Méthodes héritées de la classe Inspectable

__init_subclass__, __subclasshook__

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__

Vous êtes un professionnel et vous avez besoin d'une formation ? RAG (Retrieval-Augmented Generation)
et Fine Tuning d'un LLM
Voir le programme détaillé