本文整理汇总了Python中mysqlstmt.Select.columns方法的典型用法代码示例。如果您正苦于以下问题:Python Select.columns方法的具体用法?Python Select.columns怎么用?Python Select.columns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqlstmt.Select
的用法示例。
在下文中一共展示了Select.columns方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_join_root_field
# 需要导入模块: from mysqlstmt import Select [as 别名]
# 或者: from mysqlstmt.Select import columns [as 别名]
def test_join_root_field(self):
# join(table, '.Field1')
# JOIN table ON (root_table.Field1 = table.Field1)
q = Select()
sql_t = q.columns(['t1c1', 't2c1']).from_table('t1').left_join('t2', '.t1c1').sql()
assert_equals(sql_t, ('SELECT `t1c1`, `t2c1` FROM t1 LEFT JOIN t2 ON (t1.`t1c1` = t2.`t1c1`)', None))
示例2: test_join_no_root
# 需要导入模块: from mysqlstmt import Select [as 别名]
# 或者: from mysqlstmt.Select import columns [as 别名]
def test_join_no_root(self):
q = Select()
q.columns(['t1c1', 't2c1']).left_join('t2', 't1c1').sql()
示例3: test_join_field
# 需要导入模块: from mysqlstmt import Select [as 别名]
# 或者: from mysqlstmt.Select import columns [as 别名]
def test_join_field(self):
# join(table, 'Field1')
# JOIN table USING (Field1)
q = Select()
sql_t = q.columns(['t1c1', 't2c1']).from_table('t1').left_join('t2', 't1c1').sql()
assert_equals(sql_t, ('SELECT `t1c1`, `t2c1` FROM t1 LEFT JOIN t2 USING (`t1c1`)', None))
示例4: test_join_root_field_multi_dotdot
# 需要导入模块: from mysqlstmt import Select [as 别名]
# 或者: from mysqlstmt.Select import columns [as 别名]
def test_join_root_field_multi_dotdot(self):
# join(table, '..Field1')
# JOIN table ON (previous_join_table.Field1 = table.Field1)
q = Select()
sql_t = q.columns(['t1c1', 't2c1', 't3c1']).from_table('t1').left_join('t2', '..t1c1').left_join('t3', '..t2c1').sql()
assert_equals(sql_t, ('SELECT `t1c1`, `t2c1`, `t3c1` FROM t1 LEFT JOIN t2 ON (t1.`t1c1` = t2.`t1c1`) LEFT JOIN t3 ON (t2.`t2c1` = t3.`t2c1`)', None))
示例5: test_join_root_field_tableas
# 需要导入模块: from mysqlstmt import Select [as 别名]
# 或者: from mysqlstmt.Select import columns [as 别名]
def test_join_root_field_tableas(self):
# join(table, '.Field1')
# JOIN table ON (root_table.Field1 = table.Field1)
q = Select()
sql_t = q.columns(['t1a.c1', 't2a.c1']).from_table('t1 AS t1a').left_join('t2 AS t2a', '.t1c1').sql()
assert_equals(sql_t, ('SELECT t1a.`c1`, t2a.`c1` FROM t1 AS t1a LEFT JOIN t2 AS t2a ON (t1a.`t1c1` = t2a.`t1c1`)', None))
示例6: test_join_conditions
# 需要导入模块: from mysqlstmt import Select [as 别名]
# 或者: from mysqlstmt.Select import columns [as 别名]
def test_join_conditions(self):
# join(table, [condition,...])
# JOIN table ON (condition [AND condition [AND ...]])
q = Select()
sql_t = q.columns(['t1c1', 't2c1']).from_table('t1').left_join('t2', ['t1c1 = t2c1']).sql()
assert_equals(sql_t, ('SELECT `t1c1`, `t2c1` FROM t1 LEFT JOIN t2 ON (t1c1 = t2c1)', None))
示例7: test_join_field_list
# 需要导入模块: from mysqlstmt import Select [as 别名]
# 或者: from mysqlstmt.Select import columns [as 别名]
def test_join_field_list(self):
# when join_cond is ('Field1', 'Field2', ...)
# JOIN table USING (Field1, Field2, ...)
q = Select()
sql_t = q.columns(['t1c1', 't2c1']).from_table('t1').left_join('t2', ('t1c1', 't2c1')).sql()
assert_equals(sql_t, ('SELECT `t1c1`, `t2c1` FROM t1 LEFT JOIN t2 USING (`t1c1`, `t2c1`)', None))
示例8: test_constructor_table_name
# 需要导入模块: from mysqlstmt import Select [as 别名]
# 或者: from mysqlstmt.Select import columns [as 别名]
def test_constructor_table_name(self):
q = Select('t1')
sql_t = q.columns('t1c1').sql()
assert_equals(sql_t, ('SELECT `t1c1` FROM t1', None))