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


Python elements.quoted_name方法代码示例

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


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

示例1: test_quoted_name_bindparam_ok

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def test_quoted_name_bindparam_ok(self):
        from sqlalchemy.sql.elements import quoted_name

        with testing.db.connect() as conn:
            eq_(
                conn.scalar(
                    select(
                        [
                            cast(
                                literal(quoted_name("some_name", False)),
                                String,
                            )
                        ]
                    )
                ),
                "some_name",
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:19,代码来源:test_dialect.py

示例2: test_named_alias_disable_quote

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def test_named_alias_disable_quote(self):
        cte = select([literal(1).label("id")]).cte(
            name=quoted_name("CTE", quote=False)
        )

        s1 = select([cte.c.id]).alias(
            name=quoted_name("DontQuote", quote=False)
        )

        s = select([s1])
        self.assert_compile(
            s,
            "WITH CTE AS (SELECT :param_1 AS id) "
            "SELECT DontQuote.id FROM "
            "(SELECT CTE.id AS id FROM CTE) AS DontQuote",
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:18,代码来源:test_cte.py

示例3: normalize_name

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [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

示例4: _gen_label

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def _gen_label(self, name):
        t = self.table

        if self.is_literal:
            return None

        elif t is not None and t.named_with_column:
            if getattr(t, 'schema', None):
                label = t.schema.replace('.', '_') + "_" + \
                    t.name + "_" + name
            else:
                label = t.name + "_" + name

            # propagate name quoting rules for labels.
            if getattr(name, "quote", None) is not None:
                if isinstance(label, quoted_name):
                    label.quote = name.quote
                else:
                    label = quoted_name(label, name.quote)
            elif getattr(t.name, "quote", None) is not None:
                # can't get this situation to occur, so let's
                # assert false on it for now
                assert not isinstance(label, quoted_name)
                label = quoted_name(label, t.name.quote)

            # ensure the label name doesn't conflict with that
            # of an existing column
            if label in t.c:
                _label = label
                counter = 1
                while _label in t.c:
                    _label = label + "_" + str(counter)
                    counter += 1
                label = _label

            return _as_truncated(label)

        else:
            return name 
开发者ID:jpush,项目名称:jbox,代码行数:41,代码来源:elements.py

示例5: __new__

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def __new__(cls, value, quote):
        if value is None:
            return None
        # experimental - don't bother with quoted_name
        # if quote flag is None.  doesn't seem to make any dent
        # in performance however
        # elif not sprcls and quote is None:
        #   return value
        elif isinstance(value, cls) and (
            quote is None or value.quote == quote
        ):
            return value
        self = super(quoted_name, cls).__new__(cls, value)
        self.quote = quote
        return self 
开发者ID:jpush,项目名称:jbox,代码行数:17,代码来源:elements.py

示例6: __reduce__

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def __reduce__(self):
        return quoted_name, (util.text_type(self), self.quote) 
开发者ID:jpush,项目名称:jbox,代码行数:4,代码来源:elements.py

示例7: __add__

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def __add__(self, other):
        return _anonymous_label(
            quoted_name(
                util.text_type.__add__(self, util.text_type(other)),
                self.quote)
        ) 
开发者ID:jpush,项目名称:jbox,代码行数:8,代码来源:elements.py

示例8: apply_map

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def apply_map(self, map_):
        if self.quote is not None:
            # preserve quoting only if necessary
            return quoted_name(self % map_, self.quote)
        else:
            # else skip the constructor call
            return self % map_ 
开发者ID:jpush,项目名称:jbox,代码行数:9,代码来源:elements.py

示例9: quote_dotted

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def quote_dotted(name, quote):
    """quote the elements of a dotted name"""

    if util.sqla_09 and isinstance(name, quoted_name):
        return quote(name)
    result = '.'.join([quote(x) for x in name.split('.')])
    return result 
开发者ID:jpush,项目名称:jbox,代码行数:9,代码来源:base.py

示例10: normalize_name

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def normalize_name(self, name):
        if name is None:
            return None

        if name.upper() == name and not \
           self.identifier_preparer._requires_quotes(name.lower()):
            name = name.lower()
        elif name.lower() == name:
            return quoted_name(name, quote=True)

        return name 
开发者ID:SAP,项目名称:sqlalchemy-hana,代码行数:13,代码来源:dialect.py

示例11: quote_dotted

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def quote_dotted(name, quote):
    """quote the elements of a dotted name"""

    if isinstance(name, quoted_name):
        return quote(name)
    result = ".".join([quote(x) for x in name.split(".")])
    return result 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:9,代码来源:base.py

示例12: _get_constraint_final_name

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def _get_constraint_final_name(constraint, dialect):
    if constraint.name is None:
        return None
    elif sqla_14:
        # for SQLAlchemy 1.4 we would like to have the option to expand
        # the use of "deferred" names for constraints as well as to have
        # some flexibility with "None" name and similar; make use of new
        # SQLAlchemy API to return what would be the final compiled form of
        # the name for this dialect.
        return dialect.identifier_preparer.format_constraint(
            constraint, _alembic_quote=False
        )
    else:

        # prior to SQLAlchemy 1.4, work around quoting logic to get at the
        # final compiled name without quotes.
        if hasattr(constraint.name, "quote"):
            # might be quoted_name, might be truncated_name, keep it the
            # same
            quoted_name_cls = type(constraint.name)
        else:
            quoted_name_cls = quoted_name

        new_name = quoted_name_cls(str(constraint.name), quote=False)
        constraint = constraint.__class__(name=new_name)

        if isinstance(constraint, schema.Index):
            # name should not be quoted.
            return dialect.ddl_compiler(dialect, None)._prepared_index_name(
                constraint
            )
        else:
            # name should not be quoted.
            return dialect.identifier_preparer.format_constraint(constraint) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:36,代码来源:sqla_compat.py

示例13: normalize_name

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def normalize_name(self, name):
        # Remove trailing spaces: FB uses a CHAR() type,
        # that is padded with spaces
        name = name and name.rstrip()
        if name is None:
            return None
        elif 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:yfauser,项目名称:planespotter,代码行数:15,代码来源:base.py

示例14: define_tables

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def define_tables(cls, metadata):
        Table(
            quoted_name('t1', quote=True), metadata,
            Column('id', Integer, primary_key=True),
        )
        Table(
            quoted_name('t2', quote=True), metadata,
            Column('id', Integer, primary_key=True),
            Column('t1id', ForeignKey('t1.id'))
        ) 
开发者ID:yfauser,项目名称:planespotter,代码行数:12,代码来源:test_reflection.py

示例15: test_reflect_lowercase_forced_tables

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import quoted_name [as 别名]
def test_reflect_lowercase_forced_tables(self):

        m2 = MetaData(testing.db)
        t2_ref = Table(quoted_name('t2', quote=True), m2, autoload=True)
        t1_ref = m2.tables['t1']
        assert t2_ref.c.t1id.references(t1_ref.c.id)

        m3 = MetaData(testing.db)
        m3.reflect(only=lambda name, m: name.lower() in ('t1', 't2'))
        assert m3.tables['t2'].c.t1id.references(m3.tables['t1'].c.id) 
开发者ID:yfauser,项目名称:planespotter,代码行数:12,代码来源:test_reflection.py


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