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


Python elements.BindParameter方法代码示例

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


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

示例1: test_ensure_repr_elements

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import BindParameter [as 别名]
def test_ensure_repr_elements(self):
        for obj in [
            elements.Cast(1, 2),
            elements.TypeClause(String()),
            elements.ColumnClause("x"),
            elements.BindParameter("q"),
            elements.Null(),
            elements.True_(),
            elements.False_(),
            elements.ClauseList(),
            elements.BooleanClauseList._construct_raw(operators.and_),
            elements.BooleanClauseList._construct_raw(operators.or_),
            elements.Tuple(),
            elements.Case([]),
            elements.Extract("foo", column("x")),
            elements.UnaryExpression(column("x")),
            elements.Grouping(column("x")),
            elements.Over(func.foo()),
            elements.Label("q", column("x")),
        ]:
            repr(obj) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:23,代码来源:test_selectable.py

示例2: test_bindparam_subclass_nocache

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import BindParameter [as 别名]
def test_bindparam_subclass_nocache(self):
        # does not implement inherit_cache
        class _literal_bindparam(BindParameter):
            pass

        l1 = _literal_bindparam(None, value="x1")
        is_(l1._generate_cache_key(), None) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:9,代码来源:test_compare.py

示例3: test_bindparam_subclass_ok_cache

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import BindParameter [as 别名]
def test_bindparam_subclass_ok_cache(self):
        # implements inherit_cache
        class _literal_bindparam(BindParameter):
            inherit_cache = True

        def fixture():
            return (
                _literal_bindparam(None, value="x1"),
                _literal_bindparam(None, value="x2"),
                _literal_bindparam(None),
            )

        self._run_cache_key_fixture(fixture, True) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:15,代码来源:test_compare.py

示例4: _statements_w_anonymous_col_names

# 需要导入模块: from sqlalchemy.sql import elements [as 别名]
# 或者: from sqlalchemy.sql.elements import BindParameter [as 别名]
def _statements_w_anonymous_col_names():
        def one():
            c = column("q")

            l = c.label(None)

            # new case as of Id810f485c5f7ed971529489b84694e02a3356d6d
            subq = select([l]).subquery()

            # this creates a ColumnClause as a proxy to the Label() that has
            # an anoymous name, so the column has one too.
            anon_col = subq.c[0]

            # then when BindParameter is created, it checks the label
            # and doesn't double up on the anonymous name which is uncachable
            return anon_col > 5

        def two():
            c = column("p")

            l = c.label(None)

            # new case as of Id810f485c5f7ed971529489b84694e02a3356d6d
            subq = select([l]).subquery()

            # this creates a ColumnClause as a proxy to the Label() that has
            # an anoymous name, so the column has one too.
            anon_col = subq.c[0]

            # then when BindParameter is created, it checks the label
            # and doesn't double up on the anonymous name which is uncachable
            return anon_col > 5

        def three():

            l1, l2 = table_a.c.a.label(None), table_a.c.b.label(None)

            stmt = select([table_a.c.a, table_a.c.b, l1, l2])

            subq = stmt.subquery()
            return select([subq]).where(subq.c[2] == 10)

        return (
            one(),
            two(),
            three(),
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:49,代码来源:test_compare.py


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