本文整理汇总了Python中pypika.Query.into方法的典型用法代码示例。如果您正苦于以下问题:Python Query.into方法的具体用法?Python Query.into怎么用?Python Query.into使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypika.Query
的用法示例。
在下文中一共展示了Query.into方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_insert_columns_from_star
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_columns_from_star(self):
query = Query.into(self.table_abc).columns(
self.table_abc.foo, self.table_abc.bar, self.table_abc.buz,
).from_(self.table_efg).select('*')
self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") '
'SELECT * FROM "efg"', str(query))
示例2: test_insert_from_columns
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_from_columns(self):
query = Query.into(self.table_abc).from_(self.table_efg).select(
self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz
)
self.assertEqual('INSERT INTO "abc" '
'SELECT "fiz","buz","baz" FROM "efg"', str(query))
示例3: test_insert_all_columns_multi_rows_chained_mixed
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_all_columns_multi_rows_chained_mixed(self):
query = Query.into(self.table_abc).insert(
(1, 'a', True), (2, 'b', False)
).insert(3, 'c', True)
self.assertEqual('INSERT INTO "abc" VALUES '
'(1,\'a\',true),(2,\'b\',false),'
'(3,\'c\',true)', str(query))
示例4: test_join_table_on_insert_query
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_join_table_on_insert_query(self):
a, b, c = Tables('a', 'b', 'c')
q = Query.into(c).from_(a) \
.join(b).on(a.fkey_id == b.id) \
.where(b.foo == 1) \
.select('a.*', 'b.*')
self.assertEqual('INSERT INTO "c" '
'SELECT "a"."a.*","a"."b.*" '
'FROM "a" JOIN "b" '
'ON "a"."fkey_id"="b"."id" '
'WHERE "b"."foo"=1', str(q))
示例5: test_insert_subquery_wrapped_in_brackets
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_subquery_wrapped_in_brackets(self):
purchase_order_item, part = Tables("purchase_order_item", "part")
q = Query.into(purchase_order_item) \
.columns(purchase_order_item.id_part, purchase_order_item.id_customer) \
.insert(Query.from_(part)
.select(part.part_id)
.where(part.part_number == "FOOBAR"), 12345)
self.assertEqual('INSERT INTO "purchase_order_item" '
'("id_part","id_customer") '
'VALUES '
'((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', str(q))
示例6: test_insert_columns_from_columns_with_join
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_columns_from_columns_with_join(self):
query = Query.into(self.table_abc).columns(
self.table_abc.c1, self.table_abc.c2, self.table_abc.c3, self.table_abc.c4
).from_(self.table_efg).select(
self.table_efg.foo, self.table_efg.bar
).join(self.table_hij).on(
self.table_efg.id == self.table_hij.abc_id
).select(
self.table_hij.fiz, self.table_hij.buz
)
self.assertEqual('INSERT INTO "abc" ("c1","c2","c3","c4") '
'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" '
'JOIN "hij" ON "efg"."id"="hij"."abc_id"', str(query))
示例7: test_insert_none_skipped
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_none_skipped(self):
query = Query.into(self.table_abc).insert()
self.assertEqual('', str(query))
示例8: test_insert_ignore
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_ignore(self):
query = Query.into(self.table_abc).insert(1).ignore()
self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query))
示例9: test_insert_one_column
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_one_column(self):
query = Query.into(self.table_abc).insert(1)
self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query))
示例10: test_insert_selected_columns
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_selected_columns(self):
query = Query.into(self.table_abc).columns(
self.table_abc.foo, self.table_abc.bar, self.table_abc.buz
).insert(1, 'a', True)
self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query))
示例11: test_insert_all_columns_single_element
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_all_columns_single_element(self):
query = Query.into(self.table_abc).insert((1, 'a', True))
self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query))
示例12: test_insert_all_columns_multi_rows
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_all_columns_multi_rows(self):
query = Query.into(self.table_abc).insert((1, 'a', True), (2, 'b', False))
self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true),(2,\'b\',false)', str(query))
示例13: test_insert_multiple_rows_with_array_value
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_multiple_rows_with_array_value(self):
query = Query.into(self.table_abc).insert((1, ['a', 'b', 'c']),
(2, ['c', 'd', 'e']), )
self.assertEqual('INSERT INTO "abc" '
'VALUES (1,[\'a\',\'b\',\'c\']),(2,[\'c\',\'d\',\'e\'])', str(query))
示例14: test_insert_one_column_multi_element_array
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_one_column_multi_element_array(self):
query = Query.into(self.table_abc).insert((1,), (2,))
self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query))
示例15: test_insert_null
# 需要导入模块: from pypika import Query [as 别名]
# 或者: from pypika.Query import into [as 别名]
def test_insert_null(self):
query = Query.into(self.table_abc).insert(None)
self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query))