• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python visitor.get_engine_visitor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中migrate.changeset.databases.visitor.get_engine_visitor函数的典型用法代码示例。如果您正苦于以下问题:Python get_engine_visitor函数的具体用法?Python get_engine_visitor怎么用?Python get_engine_visitor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_engine_visitor函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: alter_column

def alter_column(*p, **k):
    """Alter a column.

    Direct API to :class:`ColumnDelta`.

    :param table: Table or table name (will issue reflection).
    :param engine: Will be used for reflection.
    :param alter_metadata: Defaults to True. It will alter changes also to objects.
    :returns: :class:`Columndelta` instance
    """
    
    k.setdefault('alter_metadata', DEFAULT_ALTER_METADATA)

    if 'table' not in k and isinstance(p[0], sqlalchemy.Column):
        k['table'] = p[0].table
    if 'engine' not in k:
        k['engine'] = k['table'].bind

    # deprecation
    if len(p) >= 2 and isinstance(p[1], sqlalchemy.Column):
        warnings.warn("Alter column with comparing columns is deprecated."
            " Just pass in parameters instead.", MigrateDeprecationWarning)
    engine = k['engine']
    delta = ColumnDelta(*p, **k)

    visitorcallable = get_engine_visitor(engine, 'schemachanger')
    engine._run_visitor(visitorcallable, delta)

    return delta
开发者ID:hgroll,项目名称:yocto-autobuilder,代码行数:29,代码来源:schema.py


示例2: drop

 def drop(self):
     from migrate.changeset.databases.visitor import get_engine_visitor
     visitorcallable = get_engine_visitor(self.table.bind,
                                          'constraintdropper')
     _engine_run_visitor(self.table.bind, visitorcallable, self)
     self.columns.clear()
     return self
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:7,代码来源:constraint.py


示例3: create

    def create(self, table=None, *args, **kwargs):
        """Create this column in the database.

        Assumes the given table exists. ``ALTER TABLE ADD COLUMN``,
        for most databases.
        """
        table = _normalize_table(self, table)
        engine = table.bind
        visitorcallable = get_engine_visitor(engine, 'columngenerator')
        engine._run_visitor(visitorcallable, self, *args, **kwargs)

        #add in foreign keys
        if self.foreign_keys:
            for fk in self.foreign_keys:
                visitorcallable = get_engine_visitor(engine,
                                                     'columnfkgenerator')
                engine._run_visitor(visitorcallable, self, fk=fk)
        return self
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:18,代码来源:schema.py


示例4: drop

    def drop(self, table=None, *args, **kwargs):
        """Drop this column from the database, leaving its table intact.

        ``ALTER TABLE DROP COLUMN``, for most databases.
        """
        table = _normalize_table(self, table)
        engine = table.bind
        visitorcallable = get_engine_visitor(engine, 'columndropper')
        engine._run_visitor(lambda dialect, conn: visitorcallable(conn),
                            self, *args, **kwargs)
        return self
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:11,代码来源:schema.py


示例5: rename

    def rename(self, name, connection=None, **kwargs):
        """Change the name of an index.

        :param name: New name of the Index.
        :type name: string
        :param connection: reuse connection istead of creating new one.
        :type connection: :class:`sqlalchemy.engine.base.Connection` instance
        """
        engine = self.table.bind
        self.new_name = name
        visitorcallable = get_engine_visitor(engine, 'schemachanger')
        engine._run_visitor(visitorcallable, self, connection, **kwargs)
        self.name = name
开发者ID:marinamarina,项目名称:website,代码行数:13,代码来源:schema.py


示例6: alter_column

def alter_column(*p, **k):
    """Alter a column.

    This is a helper function that creates a :class:`ColumnDelta` and
    runs it.

    :argument column:
      The name of the column to be altered or a
      :class:`ChangesetColumn` column representing it.

    :param table:
      A :class:`~sqlalchemy.schema.Table` or table name to
      for the table where the column will be changed.

    :param engine:
      The :class:`~sqlalchemy.engine.base.Engine` to use for table
      reflection and schema alterations.

    :returns: A :class:`ColumnDelta` instance representing the change.


    """

    if 'table' not in k and isinstance(p[0], sqlalchemy.Column):
        k['table'] = p[0].table
    if 'engine' not in k:
        k['engine'] = k['table'].bind

    # deprecation
    if len(p) >= 2 and isinstance(p[1], sqlalchemy.Column):
        warnings.warn(
            "Passing a Column object to alter_column is deprecated."
            " Just pass in keyword parameters instead.",
            MigrateDeprecationWarning
            )
    engine = k['engine']

    # enough tests seem to break when metadata is always altered
    # that this crutch has to be left in until they can be sorted
    # out
    k['alter_metadata']=True

    delta = ColumnDelta(*p, **k)

    visitorcallable = get_engine_visitor(engine, 'schemachanger')
    engine._run_visitor(visitorcallable, delta)

    return delta
开发者ID:marinamarina,项目名称:website,代码行数:48,代码来源:schema.py


示例7: drop

    def drop(self, table=None, connection=None, **kwargs):
        """Drop this column from the database, leaving its table intact.

        ``ALTER TABLE DROP COLUMN``, for most databases.

        :param connection: reuse connection istead of creating new one.
        :type connection: :class:`sqlalchemy.engine.base.Connection` instance
        """
        if table is not None:
            self.table = table
        engine = self.table.bind
        visitorcallable = get_engine_visitor(engine, 'columndropper')
        engine._run_visitor(visitorcallable, self, connection, **kwargs)
        self.remove_from_table(self.table, unset_table=False)
        self.table = None
        return self
开发者ID:marinamarina,项目名称:website,代码行数:16,代码来源:schema.py


示例8: create

    def create(self, table=None, index_name=None, unique_name=None,
               primary_key_name=None, populate_default=True, connection=None, **kwargs):
        """Create this column in the database.

        Assumes the given table exists. ``ALTER TABLE ADD COLUMN``,
        for most databases.

        :param table: Table instance to create on.
        :param index_name: Creates :class:`ChangesetIndex` on this column.
        :param unique_name: Creates :class:\
`~migrate.changeset.constraint.UniqueConstraint` on this column.
        :param primary_key_name: Creates :class:\
`~migrate.changeset.constraint.PrimaryKeyConstraint` on this column.
        :param alter_metadata: If True, column will be added to table object.
        :param populate_default: If True, created column will be \
populated with defaults
        :param connection: reuse connection istead of creating new one.
        :type table: Table instance
        :type index_name: string
        :type unique_name: string
        :type primary_key_name: string
        :type alter_metadata: bool
        :type populate_default: bool
        :type connection: :class:`sqlalchemy.engine.base.Connection` instance

        :returns: self
        """
        self.populate_default = populate_default
        self.alter_metadata = kwargs.pop('alter_metadata', DEFAULT_ALTER_METADATA)
        self.index_name = index_name
        self.unique_name = unique_name
        self.primary_key_name = primary_key_name
        for cons in ('index_name', 'unique_name', 'primary_key_name'):
            self._check_sanity_constraints(cons)

        if self.alter_metadata:
            self.add_to_table(table)
        engine = self.table.bind
        visitorcallable = get_engine_visitor(engine, 'columngenerator')
        engine._run_visitor(visitorcallable, self, connection, **kwargs)

        # TODO: reuse existing connection
        if self.populate_default and self.default is not None:
            stmt = table.update().values({self: engine._execute_default(self.default)})
            engine.execute(stmt)

        return self
开发者ID:hgroll,项目名称:yocto-autobuilder,代码行数:47,代码来源:schema.py


示例9: rename

    def rename(self, name, connection=None, **kwargs):
        """Change the name of an index.

        :param name: New name of the Index.
        :type name: string
        :param alter_metadata: If True, Index object will be altered.
        :type alter_metadata: bool
        :param connection: reuse connection istead of creating new one.
        :type connection: :class:`sqlalchemy.engine.base.Connection` instance
        """
        self.alter_metadata = kwargs.pop('alter_metadata', DEFAULT_ALTER_METADATA)
        engine = self.table.bind
        self.new_name = name
        visitorcallable = get_engine_visitor(engine, 'schemachanger')
        engine._run_visitor(visitorcallable, self, connection, **kwargs)
        if self.alter_metadata:
            self.name = name
开发者ID:hgroll,项目名称:yocto-autobuilder,代码行数:17,代码来源:schema.py


示例10: drop

    def drop(self, table=None, connection=None, **kwargs):
        """Drop this column from the database, leaving its table intact.

        ``ALTER TABLE DROP COLUMN``, for most databases.

        :param alter_metadata: If True, column will be removed from table object.
        :type alter_metadata: bool
        :param connection: reuse connection istead of creating new one.
        :type connection: :class:`sqlalchemy.engine.base.Connection` instance
        """
        self.alter_metadata = kwargs.pop('alter_metadata', DEFAULT_ALTER_METADATA)
        if table is not None:
            self.table = table
        engine = self.table.bind
        if self.alter_metadata:
            self.remove_from_table(self.table, unset_table=False)
        visitorcallable = get_engine_visitor(engine, 'columndropper')
        engine._run_visitor(visitorcallable, self, connection, **kwargs)
        if self.alter_metadata:
            self.table = None
        return self
开发者ID:hgroll,项目名称:yocto-autobuilder,代码行数:21,代码来源:schema.py


示例11: __do_imports

 def __do_imports(self, visitor_name, *a, **kw):
     engine = kw.pop('engine', self.table.bind)
     from migrate.changeset.databases.visitor import (get_engine_visitor,
                                                      run_single_visitor)
     visitorcallable = get_engine_visitor(engine, visitor_name)
     run_single_visitor(engine, visitorcallable, self, *a, **kw)
开发者ID:hgroll,项目名称:yocto-autobuilder,代码行数:6,代码来源:constraint.py



注:本文中的migrate.changeset.databases.visitor.get_engine_visitor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.create函数代码示例发布时间:2022-05-27
下一篇:
Python constraint.UniqueConstraint类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap