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


Python util.py2k方法代码示例

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


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

示例1: get_view_definition

# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import py2k [as 别名]
def get_view_definition(self, connection, view_name, schema=None,
                            resolve_synonyms=False, dblink='', **kw):
        info_cache = kw.get('info_cache')
        (view_name, schema, dblink, synonym) = \
            self._prepare_reflection_args(connection, view_name, schema,
                                          resolve_synonyms, dblink,
                                          info_cache=info_cache)

        params = {'view_name': view_name}
        text = "SELECT text FROM all_views WHERE view_name=:view_name"

        if schema is not None:
            text += " AND owner = :schema"
            params['schema'] = schema

        rp = connection.execute(sql.text(text), **params).scalar()
        if rp:
            if util.py2k:
                rp = rp.decode(self.encoding)
            return rp
        else:
            return None 
开发者ID:jpush,项目名称:jbox,代码行数:24,代码来源:base.py

示例2: get_table_names

# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import py2k [as 别名]
def get_table_names(self, connection, schema=None, **kw):
        if schema is None:
            schema = self.default_schema_name

        TABLE_SQL = text("""
          SELECT o.name AS name
          FROM sysobjects o JOIN sysusers u ON o.uid = u.uid
          WHERE u.name = :schema_name
            AND o.type = 'U'
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")

        tables = connection.execute(TABLE_SQL, schema_name=schema)

        return [t["name"] for t in tables] 
开发者ID:jpush,项目名称:jbox,代码行数:20,代码来源:base.py

示例3: get_view_names

# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import py2k [as 别名]
def get_view_names(self, connection, schema=None, **kw):
        if schema is None:
            schema = self.default_schema_name

        VIEW_SQL = text("""
          SELECT o.name AS name
          FROM sysobjects o JOIN sysusers u ON o.uid = u.uid
          WHERE u.name = :schema_name
            AND o.type = 'V'
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
        views = connection.execute(VIEW_SQL, schema_name=schema)

        return [v["name"] for v in views] 
开发者ID:jpush,项目名称:jbox,代码行数:19,代码来源:base.py

示例4: _expect_failure

# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import py2k [as 别名]
def _expect_failure(self, config, ex, combination, name="block"):
        for fail in self.fails:
            if self._check_combinations(combination, fail) and fail(config):
                if sqla_util.py2k:
                    str_ex = unicode(ex).encode(  # noqa: F821
                        "utf-8", errors="ignore"
                    )
                else:
                    str_ex = str(ex)
                print(
                    (
                        "%s failed as expected (%s): %s "
                        % (name, fail._as_string(config), str_ex)
                    )
                )
                break
        else:
            util.raise_from_cause(ex) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:20,代码来源:exclusions.py

示例5: get_view_definition

# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import py2k [as 别名]
def get_view_definition(self, connection, view_name, schema=None, **kw):
        if schema is None:
            schema = self.default_schema_name

        VIEW_DEF_SQL = text("""
          SELECT c.text
          FROM syscomments c JOIN sysobjects o ON c.id = o.id
          WHERE o.name = :view_name
            AND o.type = 'V'
        """)

        if util.py2k:
            if isinstance(view_name, unicode):
                view_name = view_name.encode("ascii")

        view = connection.execute(VIEW_DEF_SQL, view_name=view_name)

        return view.scalar() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:base.py

示例6: get_table_names

# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import py2k [as 别名]
def get_table_names(self, connection, schema=None, **kw):
        if schema is None:
            schema = self.default_schema_name

        TABLE_SQL = text(
            """
          SELECT o.name AS name
          FROM sysobjects o JOIN sysusers u ON o.uid = u.uid
          WHERE u.name = :schema_name
            AND o.type = 'U'
        """
        )

        if util.py2k:
            if isinstance(schema, unicode):  # noqa
                schema = schema.encode("ascii")

        tables = connection.execute(TABLE_SQL, schema_name=schema)

        return [t["name"] for t in tables] 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:22,代码来源:base.py

示例7: get_view_definition

# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import py2k [as 别名]
def get_view_definition(self, connection, view_name, schema=None, **kw):
        if schema is None:
            schema = self.default_schema_name

        VIEW_DEF_SQL = text(
            """
          SELECT c.text
          FROM syscomments c JOIN sysobjects o ON c.id = o.id
          WHERE o.name = :view_name
            AND o.type = 'V'
        """
        )

        if util.py2k:
            if isinstance(view_name, unicode):  # noqa
                view_name = view_name.encode("ascii")

        view = connection.execute(VIEW_DEF_SQL, view_name=view_name)

        return view.scalar() 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:22,代码来源:base.py

示例8: get_view_names

# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import py2k [as 别名]
def get_view_names(self, connection, schema=None, **kw):
        if schema is None:
            schema = self.default_schema_name

        VIEW_SQL = text(
            """
          SELECT o.name AS name
          FROM sysobjects o JOIN sysusers u ON o.uid = u.uid
          WHERE u.name = :schema_name
            AND o.type = 'V'
        """
        )

        if util.py2k:
            if isinstance(schema, unicode):  # noqa
                schema = schema.encode("ascii")
        views = connection.execute(VIEW_SQL, schema_name=schema)

        return [v["name"] for v in views] 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:21,代码来源:base.py

示例9: unicode_ddl

# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import py2k [as 别名]
def unicode_ddl(self):
        """Target driver must support some degree of non-ascii symbol names."""
        # TODO: expand to exclude MySQLdb versions w/ broken unicode

        return skip_if(
            [
                no_support("oracle", "FIXME: no support in database?"),
                no_support("sybase", "FIXME: guessing, needs confirmation"),
                no_support("mssql+pymssql", "no FreeTDS support"),
                LambdaPredicate(
                    lambda config: against(config, "mysql+mysqlconnector")
                    and config.db.dialect._mysqlconnector_version_info > (2, 0)
                    and util.py2k,
                    "bug in mysqlconnector 2.0",
                ),
                exclude(
                    "mysql", "<", (4, 1, 1), "no unicode connection support"
                ),
            ]
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:22,代码来源:requirements.py

示例10: normalize_name

# 需要导入模块: from sqlalchemy import util [as 别名]
# 或者: from sqlalchemy.util import py2k [as 别名]
def normalize_name(self, name):
        if name is None:
            return None
        if util.py2k:
            if isinstance(name, str):
                name = name.decode(self.encoding)
        if name.upper() == name and not \
                self.identifier_preparer._requires_quotes(name.lower()):
            return name.lower()
        elif name.lower() == name:
            return quoted_name(name, quote=True)
        else:
            return name 
开发者ID:jpush,项目名称:jbox,代码行数:15,代码来源:base.py


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