當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。