sqlalchemy.table

Here are the examples of the python api sqlalchemy.table taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

7 Examples 7

Example 1

Project: sqlalchemy Source File: test_insert.py
    def test_unconsumed_names_kwargs(self):
        t = table("t", column("x"), column("y"))
        assert_raises_message(
            exc.CompileError,
            "Unconsumed column names: z",
            t.insert().values(x=5, z=5).compile,
        )

Example 2

Project: sqlalchemy Source File: test_insert.py
    def test_bindparam_name_no_consume_error(self):
        t = table("t", column("x"), column("y"))
        # bindparam names don't get counted
        i = t.insert().values(x=3 + bindparam('x2'))
        self.assert_compile(
            i,
            "INSERT INTO t (x) VALUES ((:param_1 + :x2))"
        )

        # even if in the params list
        i = t.insert().values(x=3 + bindparam('x2'))
        self.assert_compile(
            i,
            "INSERT INTO t (x) VALUES ((:param_1 + :x2))",
            params={"x2": 1}
        )

Example 3

Project: sqlalchemy Source File: test_update.py
    def test_unconsumed_names_kwargs(self):
        t = table("t", column("x"), column("y"))

        assert_raises_message(
            exc.CompileError,
            "Unconsumed column names: z",
            t.update().values(x=5, z=5).compile,
        )

Example 4

Project: sqlalchemy Source File: test_update.py
    def test_unconsumed_names_values_dict(self):
        t = table("t", column("x"), column("y"))
        t2 = table("t2", column("q"), column("z"))

        assert_raises_message(
            exc.CompileError,
            "Unconsumed column names: j",
            t.update().values(x=5, j=7).values({t2.c.z: 5}).
            where(t.c.x == t2.c.q).compile,
        )

Example 5

Project: sqlalchemy Source File: test_update.py
    def test_unconsumed_names_kwargs_w_keys(self):
        t = table("t", column("x"), column("y"))

        assert_raises_message(
            exc.CompileError,
            "Unconsumed column names: j",
            t.update().values(x=5, j=7).compile,
            column_keys=['j']
        )

Example 6

Project: sqlakeyset Source File: test_paging.py
def do_core_tests(dburl):
    spec = ['b', 'd', 'id', 'c']

    cols = [column(each) for each in spec]
    ob = [OC(x).uo for x in spec]

    with S(dburl, echo=ECHO) as s:
        selectable = select(
            cols,
            from_obj=[table('t_Book')],
            whereclause=column('d') == 99,
            order_by=ob)

        check_paging(selectable=selectable, s=s)

Example 7

Project: sqlalchemy Source File: test_insert.py
    def test_insert_from_select_dont_mutate_raw_columns(self):
        # test [ticket:3603]
        from sqlalchemy import table
        table_ = table(
            'mytable',
            Column('foo', String),
            Column('bar', String, default='baz'),
        )

        stmt = select([table_.c.foo])
        insert = table_.insert().from_select(['foo'], stmt)

        self.assert_compile(stmt, "SELECT mytable.foo FROM mytable")
        self.assert_compile(
            insert,
            "INSERT INTO mytable (foo, bar) "
            "SELECT mytable.foo, :bar AS anon_1 FROM mytable"
        )
        self.assert_compile(stmt, "SELECT mytable.foo FROM mytable")
        self.assert_compile(
            insert,
            "INSERT INTO mytable (foo, bar) "
            "SELECT mytable.foo, :bar AS anon_1 FROM mytable"
        )