class_docstr: Available events for
  :class:`_engine.Connection` and :class:`_engine.Engine`.
  
  The methods here define the name of an event as well as the names of
  members that are passed to listener functions.
  
  An event listener can be associated with any
  :class:`_engine.Connection` or :class:`_engine.Engine`
  class or instance, such as an :class:`_engine.Engine`, e.g.::
  
      from sqlalchemy import event, create_engine
  
      def before_cursor_execute(conn, cursor, statement, parameters, context,
                                                      executemany):
          log.info("Received statement: %s", statement)
  
      engine = create_engine('postgresql+psycopg2://scott:tiger@localhost/test')
      event.listen(engine, "before_cursor_execute", before_cursor_execute)
  
  or with a specific :class:`_engine.Connection`::
  
      with engine.begin() as conn:
          @event.listens_for(conn, 'before_cursor_execute')
          def before_cursor_execute(conn, cursor, statement, parameters,
                                          context, executemany):
              log.info("Received statement: %s", statement)
  
  When the methods are called with a `statement` parameter, such as in
  :meth:`.after_cursor_execute` or :meth:`.before_cursor_execute`,
  the statement is the exact SQL string that was prepared for transmission
  to the DBAPI ``cursor`` in the connection's :class:`.Dialect`.
  
  The :meth:`.before_execute` and :meth:`.before_cursor_execute`
  events can also be established with the ``retval=True`` flag, which
  allows modification of the statement and parameters to be sent
  to the database.  The :meth:`.before_cursor_execute` event is
  particularly useful here to add ad-hoc string transformations, such
  as comments, to all executions::
  
      from sqlalchemy.engine import Engine
      from sqlalchemy import event
  
      @event.listens_for(Engine, "before_cursor_execute", retval=True)
      def comment_sql_calls(conn, cursor, statement, parameters,
                                          context, executemany):
          statement = statement + " -- some comment"
          return statement, parameters
  
  .. note:: :class:`_events.ConnectionEvents` can be established on any
     combination of :class:`_engine.Engine`, :class:`_engine.Connection`,
     as well
     as instances of each of those classes.  Events across all
     four scopes will fire off for a given instance of
     :class:`_engine.Connection`.  However, for performance reasons, the
     :class:`_engine.Connection` object determines at instantiation time
     whether or not its parent :class:`_engine.Engine` has event listeners
     established.   Event listeners added to the :class:`_engine.Engine`
     class or to an instance of :class:`_engine.Engine`
     *after* the instantiation
     of a dependent :class:`_engine.Connection` instance will usually
     *not* be available on that :class:`_engine.Connection` instance.
     The newly
     added listeners will instead take effect for
     :class:`_engine.Connection`
     instances created subsequent to those event listeners being
     established on the parent :class:`_engine.Engine` class or instance.
  
  :param retval=False: Applies to the :meth:`.before_execute` and
    :meth:`.before_cursor_execute` events only.  When True, the
    user-defined event function must have a return value, which
    is a tuple of parameters that replace the given statement
    and parameters.  See those methods for a description of
    specific return arguments.
class_docstr_tok: ["Available","events","for",":","class",":","`","_engine.Connection","`","and",":","class",":","`","_engine.Engine","`",".","The","methods","here","define","the","name","of","an","event","as","well","as","the","names","of","members","that","are","passed","to","listener","functions",".","An","event","listener","can","be","associated","with","any",":","class",":","`","_engine.Connection","`","or",":","class",":","`","_engine.Engine","`","class","or","instance",",","such","as","an",":","class",":","`","_engine.Engine","`",",","e.g",".",":",":","from","sqlalchemy","import","event",",","create_engine","def","before_cursor_execute","(","conn",",","cursor",",","statement",",","parameters",",","context",",","executemany",")",":","log.info","(","``","Received","statement",":","%","s","''",",","statement",")","engine","=","create_engine","(","'postgresql+psycopg2",":","\/\/scott",":","tiger","@","localhost\/test","'",")","event.listen","(","engine",",","``","before_cursor_execute","''",",","before_cursor_execute",")","or","with","a","specific",":","class",":","`","_engine.Connection","`",":",":","with","engine.begin","(",")","as","conn",":","@","event.listens_for","(","conn",",","'before_cursor_execute","'",")","def","before_cursor_execute","(","conn",",","cursor",",","statement",",","parameters",",","context",",","executemany",")",":","log.info","(","``","Received","statement",":","%","s","''",",","statement",")","When","the","methods","are","called","with","a","`","statement","`","parameter",",","such","as","in",":","meth",":","`",".after_cursor_execute","`","or",":","meth",":","`",".before_cursor_execute","`",",","the","statement","is","the","exact","SQL","string","that","was","prepared","for","transmission","to","the","DBAPI","``","cursor","``","in","the","connection","'s",":","class",":","`",".Dialect","`",".","The",":","meth",":","`",".before_execute","`","and",":","meth",":","`",".before_cursor_execute","`","events","can","also","be","established","with","the","``","retval=True","``","flag",",","which","allows","modification","of","the","statement","and","parameters","to","be","sent","to","the","database",".","The",":","meth",":","`",".before_cursor_execute","`","event","is","particularly","useful","here","to","add","ad-hoc","string","transformations",",","such","as","comments",",","to","all","executions",":",":","from","sqlalchemy.engine","import","Engine","from","sqlalchemy","import","event","@","event.listens_for","(","Engine",",","``","before_cursor_execute","''",",","retval=True",")","def","comment_sql_calls","(","conn",",","cursor",",","statement",",","parameters",",","context",",","executemany",")",":","statement","=","statement","+","``","--","some","comment","''","return","statement",",","parameters","..","note",":",":",":","class",":","`","_events.ConnectionEvents","`","can","be","established","on","any","combination","of",":","class",":","`","_engine.Engine","`",",",":","class",":","`","_engine.Connection","`",",","as","well","as","instances","of","each","of","those","classes",".","Events","across","all","four","scopes","will","fire","off","for","a","given","instance","of",":","class",":","`","_engine.Connection","`",".","However",",","for","performance","reasons",",","the",":","class",":","`","_engine.Connection","`","object","determines","at","instantiation","time","whether","or","not","its","parent",":","class",":","`","_engine.Engine","`","has","event","listeners","established",".","Event","listeners","added","to","the",":","class",":","`","_engine.Engine","`","class","or","to","an","instance","of",":","class",":","`","_engine.Engine","`","*","after","*","the","instantiation","of","a","dependent",":","class",":","`","_engine.Connection","`","instance","will","usually","*","not","*","be","available","on","that",":","class",":","`","_engine.Connection","`","instance",".","The","newly","added","listeners","will","instead","take","effect","for",":","class",":","`","_engine.Connection","`","instances","created","subsequent","to","those","event","listeners","being","established","on","the","parent",":","class",":","`","_engine.Engine","`","class","or","instance",".",":","param","retval=False",":","Applies","to","the",":","meth",":","`",".before_execute","`","and",":","meth",":","`",".before_cursor_execute","`","events","only",".","When","True",",","the","user-defined","event","function","must","have","a","return","value",",","which","is","a","tuple","of","parameters","that","replace","the","given","statement","and","parameters",".","See","those","methods","for","a","description","of","specific","return","arguments","."]
docstr: Intercept begin() events.
  
  :param conn: :class:`_engine.Connection` object
docstr_tok: ["Intercept","begin","(",")","events",".",":","param","conn",":",":","class",":","`","_engine.Connection","`","object"]
code: def begin(self, conn: Connection) -> None:
      """Intercept begin() events.
  
      :param conn: :class:`_engine.Connection` object
  
      """
  
imports: from __future__ import annotations
  import typing
  from typing import Any
  from typing import Dict
  from typing import Optional
  from typing import Tuple
  from typing import Type
  from typing import Union
  from .base import Connection
  from .base import Engine
  from .interfaces import ConnectionEventsTarget
  from .interfaces import DBAPIConnection
  from .interfaces import DBAPICursor
  from .interfaces import Dialect
  from ..None import event
  from ..None import exc
  from ..util.typing import Literal
label_desc: Use image node_id 11 for calling the ConnectionEvents obj's underlying member method code with example usage: obj.begin(conn) without return types