当前位置: 首页>>代码示例>>Python>>正文


Python func.lower方法代码示例

本文整理汇总了Python中sqlalchemy.sql.func.lower方法的典型用法代码示例。如果您正苦于以下问题:Python func.lower方法的具体用法?Python func.lower怎么用?Python func.lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy.sql.func的用法示例。


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

示例1: _validate_unique_container_name

# 需要导入模块: from sqlalchemy.sql import func [as 别名]
# 或者: from sqlalchemy.sql.func import lower [as 别名]
def _validate_unique_container_name(self, context, name):
        if not CONF.compute.unique_container_name_scope:
            return
        lowername = name.lower()
        base_query = model_query(models.Container).\
            filter(func.lower(models.Container.name) == lowername)
        if CONF.compute.unique_container_name_scope == 'project':
            container_with_same_name = base_query.\
                filter_by(project_id=context.project_id).count()
        elif CONF.compute.unique_container_name_scope == 'global':
            container_with_same_name = base_query.count()
        else:
            return

        if container_with_same_name > 0:
            raise exception.ContainerAlreadyExists(field='name',
                                                   value=lowername) 
开发者ID:openstack,项目名称:zun,代码行数:19,代码来源:api.py

示例2: add_foreign_key_constraint_if_not_exist

# 需要导入模块: from sqlalchemy.sql import func [as 别名]
# 或者: from sqlalchemy.sql.func import lower [as 别名]
def add_foreign_key_constraint_if_not_exist(
    table_name, column_name, fk_table_name, fk_column_name, driver, metadata
):
    table = Table(table_name, metadata, autoload=True, autoload_with=driver.engine)
    foreign_key_name = "{}_{}_fkey".format(table_name.lower(), column_name)

    if column_name in table.c:
        foreign_keys = [fk.name for fk in getattr(table.c, column_name).foreign_keys]
        if foreign_key_name not in foreign_keys:
            with driver.session as session:
                session.execute(
                    'ALTER TABLE "{}" ADD CONSTRAINT {} '
                    'FOREIGN KEY({}) REFERENCES "{}" ({});'.format(
                        table_name,
                        foreign_key_name,
                        column_name,
                        fk_table_name,
                        fk_column_name,
                    )
                )
                session.commit() 
开发者ID:uc-cdis,项目名称:fence,代码行数:23,代码来源:models.py

示例3: query_for_user

# 需要导入模块: from sqlalchemy.sql import func [as 别名]
# 或者: from sqlalchemy.sql.func import lower [as 别名]
def query_for_user(session, username):
    return (
        session.query(User)
        .filter(func.lower(User.username) == username.lower())
        .first()
    ) 
开发者ID:uc-cdis,项目名称:fence,代码行数:8,代码来源:models.py

示例4: set_foreign_key_constraint_on_delete

# 需要导入模块: from sqlalchemy.sql import func [as 别名]
# 或者: from sqlalchemy.sql.func import lower [as 别名]
def set_foreign_key_constraint_on_delete(
    table_name,
    column_name,
    fk_table_name,
    fk_column_name,
    ondelete,
    driver,
    session,
    metadata,
):
    with warnings.catch_warnings():
        warnings.filterwarnings(
            "ignore",
            message="Predicate of partial index \S+ ignored during reflection",
            category=sa_exc.SAWarning,
        )
        table = Table(table_name, metadata, autoload=True, autoload_with=driver.engine)
    foreign_key_name = "{}_{}_fkey".format(table_name.lower(), column_name)

    if column_name in table.c:
        session.execute(
            'ALTER TABLE ONLY "{}" DROP CONSTRAINT IF EXISTS {}, '
            'ADD CONSTRAINT {} FOREIGN KEY ({}) REFERENCES "{}" ({}) ON DELETE {};'.format(
                table_name,
                foreign_key_name,
                foreign_key_name,
                column_name,
                fk_table_name,
                fk_column_name,
                ondelete,
            )
        ) 
开发者ID:uc-cdis,项目名称:fence,代码行数:34,代码来源:models.py

示例5: drop_foreign_key_constraint_if_exist

# 需要导入模块: from sqlalchemy.sql import func [as 别名]
# 或者: from sqlalchemy.sql.func import lower [as 别名]
def drop_foreign_key_constraint_if_exist(table_name, column_name, driver, metadata):
    table = Table(table_name, metadata, autoload=True, autoload_with=driver.engine)
    foreign_key_name = "{}_{}_fkey".format(table_name.lower(), column_name)

    if column_name in table.c:
        foreign_keys = [fk.name for fk in getattr(table.c, column_name).foreign_keys]
        if foreign_key_name in foreign_keys:
            with driver.session as session:
                session.execute(
                    'ALTER TABLE "{}" DROP CONSTRAINT {};'.format(
                        table_name, foreign_key_name
                    )
                )
                session.commit() 
开发者ID:uc-cdis,项目名称:fence,代码行数:16,代码来源:models.py

示例6: get_by_username

# 需要导入模块: from sqlalchemy.sql import func [as 别名]
# 或者: from sqlalchemy.sql.func import lower [as 别名]
def get_by_username(cls, username: str) -> Optional['Puppet']:
        return cls._select_one_or_none(func.lower(cls.c.username) == username) 
开发者ID:tulir,项目名称:mautrix-telegram,代码行数:4,代码来源:puppet.py


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