/
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
sqlalchemy
/
sql
/
up file
home
� 1��fc @ s= d d l m Z d d l m Z d e j f d � � YZ d S( i ( t SchemaEventTargeti ( t eventt DDLEventsc B sb e Z d Z d Z e Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z RS( s� Define event listeners for schema objects, that is, :class:`.SchemaItem` and other :class:`.SchemaEventTarget` subclasses, including :class:`_schema.MetaData`, :class:`_schema.Table`, :class:`_schema.Column`. :class:`_schema.MetaData` and :class:`_schema.Table` support events specifically regarding when CREATE and DROP DDL is emitted to the database. Attachment events are also provided to customize behavior whenever a child schema element is associated with a parent, such as, when a :class:`_schema.Column` is associated with its :class:`_schema.Table`, when a :class:`_schema.ForeignKeyConstraint` is associated with a :class:`_schema.Table`, etc. Example using the ``after_create`` event:: from sqlalchemy import event from sqlalchemy import Table, Column, Metadata, Integer m = MetaData() some_table = Table('some_table', m, Column('data', Integer)) def after_create(target, connection, **kw): connection.execute(text( "ALTER TABLE %s SET name=foo_%s" % (target.name, target.name) )) event.listen(some_table, "after_create", after_create) DDL events integrate closely with the :class:`.DDL` class and the :class:`.DDLElement` hierarchy of DDL clause constructs, which are themselves appropriate as listener callables:: from sqlalchemy import DDL event.listen( some_table, "after_create", DDL("ALTER TABLE %(table)s SET name=foo_%(table)s") ) The methods here define the name of an event as well as the names of members that are passed to listener functions. For all :class:`.DDLEvent` events, the ``propagate=True`` keyword argument will ensure that a given event handler is propagated to copies of the object, which are made when using the :meth:`_schema.Table.to_metadata` method:: from sqlalchemy import DDL event.listen( some_table, "after_create", DDL("ALTER TABLE %(table)s SET name=foo_%(table)s"), propagate=True ) new_table = some_table.to_metadata(new_metadata) The above :class:`.DDL` object will also be associated with the :class:`_schema.Table` object represented by ``new_table``. .. seealso:: :ref:`event_toplevel` :class:`.DDLElement` :class:`.DDL` :ref:`schema_ddl_sequences` t SomeSchemaClassOrObjectc K s d S( s� Called before CREATE statements are emitted. :param target: the :class:`_schema.MetaData` or :class:`_schema.Table` object which is the target of the event. :param connection: the :class:`_engine.Connection` where the CREATE statement or statements will be emitted. :param \**kw: additional keyword arguments relevant to the event. The contents of this dictionary may vary across releases, and include the list of tables being generated for a metadata-level event, the checkfirst flag, and other elements used by internal events. :func:`.event.listen` accepts the ``propagate=True`` modifier for this event; when True, the listener function will be established for any copies made of the target object, i.e. those copies that are generated when :meth:`_schema.Table.to_metadata` is used. :func:`.event.listen` accepts the ``insert=True`` modifier for this event; when True, the listener function will be prepended to the internal list of events upon discovery, and execute before registered listener functions that do not pass this argument. N( ( t selft targett connectiont kw( ( sH /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/events.pyt before_create^ t c K s d S( s� Called after CREATE statements are emitted. :param target: the :class:`_schema.MetaData` or :class:`_schema.Table` object which is the target of the event. :param connection: the :class:`_engine.Connection` where the CREATE statement or statements have been emitted. :param \**kw: additional keyword arguments relevant to the event. The contents of this dictionary may vary across releases, and include the list of tables being generated for a metadata-level event, the checkfirst flag, and other elements used by internal events. :func:`.event.listen` also accepts the ``propagate=True`` modifier for this event; when True, the listener function will be established for any copies made of the target object, i.e. those copies that are generated when :meth:`_schema.Table.to_metadata` is used. N( ( R R R R ( ( sH /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/events.pyt after_createy R c K s d S( s� Called before DROP statements are emitted. :param target: the :class:`_schema.MetaData` or :class:`_schema.Table` object which is the target of the event. :param connection: the :class:`_engine.Connection` where the DROP statement or statements will be emitted. :param \**kw: additional keyword arguments relevant to the event. The contents of this dictionary may vary across releases, and include the list of tables being generated for a metadata-level event, the checkfirst flag, and other elements used by internal events. :func:`.event.listen` also accepts the ``propagate=True`` modifier for this event; when True, the listener function will be established for any copies made of the target object, i.e. those copies that are generated when :meth:`_schema.Table.to_metadata` is used. N( ( R R R R ( ( sH /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/events.pyt before_drop� R c K s d S( s� Called after DROP statements are emitted. :param target: the :class:`_schema.MetaData` or :class:`_schema.Table` object which is the target of the event. :param connection: the :class:`_engine.Connection` where the DROP statement or statements have been emitted. :param \**kw: additional keyword arguments relevant to the event. The contents of this dictionary may vary across releases, and include the list of tables being generated for a metadata-level event, the checkfirst flag, and other elements used by internal events. :func:`.event.listen` also accepts the ``propagate=True`` modifier for this event; when True, the listener function will be established for any copies made of the target object, i.e. those copies that are generated when :meth:`_schema.Table.to_metadata` is used. N( ( R R R R ( ( sH /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/events.pyt after_drop� R c C s d S( s Called before a :class:`.SchemaItem` is associated with a parent :class:`.SchemaItem`. :param target: the target object :param parent: the parent to which the target is being attached. :func:`.event.listen` also accepts the ``propagate=True`` modifier for this event; when True, the listener function will be established for any copies made of the target object, i.e. those copies that are generated when :meth:`_schema.Table.to_metadata` is used. N( ( R R t parent( ( sH /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/events.pyt before_parent_attach� R c C s d S( s Called after a :class:`.SchemaItem` is associated with a parent :class:`.SchemaItem`. :param target: the target object :param parent: the parent to which the target is being attached. :func:`.event.listen` also accepts the ``propagate=True`` modifier for this event; when True, the listener function will be established for any copies made of the target object, i.e. those copies that are generated when :meth:`_schema.Table.to_metadata` is used. N( ( R R R ( ( sH /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/events.pyt after_parent_attach� R c C s d S( sU internal event hook used for primary key naming convention updates. N( ( R t constt col( ( sH /opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/sql/events.pyt'