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


Python mysqlstmt.Select类代码示例

本文整理汇总了Python中mysqlstmt.Select的典型用法代码示例。如果您正苦于以下问题:Python Select类的具体用法?Python Select怎么用?Python Select使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_where_value_object

 def test_where_value_object(self):
     class TestClass(object):
         def __str__(self):
             return "object as a string"
     q = Select()
     sql_t = q.from_table('t1').where_value('t1c1', TestClass()).sql()
     assert_equals(sql_t, ('SELECT * FROM t1 WHERE `t1c1` = ?', ['object as a string']))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:7,代码来源:test_select.py

示例2: test_having_value_or

 def test_having_value_or(self):
     q = Select()
     sql_t = q.from_table('t1').having_or().having_value('t1c1', 3).having_value('t1c1', 5).sql()
     assert_equals(sql_t, ('SELECT * FROM t1 HAVING (`t1c1` = 3 OR `t1c1` = 5)', None))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例3: test_join_field

 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))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:6,代码来源:test_select.py

示例4: test_select_quote_col_func

 def test_select_quote_col_func(self):
     q = Select()
     sql_t = q.from_table('t1').columns('DATE(`t1c1`)').sql()
     assert_equals(sql_t, ('SELECT DATE(`t1c1`) FROM t1', None))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例5: test_select_distinct

 def test_select_distinct(self):
     q = Select('t1')
     sql_t = q.set_option('DISTINCT').columns('t1c1').sql()
     assert_equals(sql_t, ('SELECT DISTINCT `t1c1` FROM t1', None))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例6: test_select_no_table

 def test_select_no_table(self):
     q = Select()
     sql_t = q.column_expr('1+1').sql()
     assert_equals(sql_t, ('SELECT 1+1', None))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例7: test_join_no_root

 def test_join_no_root(self):
     q = Select()
     q.columns(['t1c1', 't2c1']).left_join('t2', 't1c1').sql()
开发者ID:lovette,项目名称:mysqlstmt,代码行数:3,代码来源:test_select.py

示例8: test_qualify_columns

 def test_qualify_columns(self):
     q = Select()
     sql_t = q.from_table('t1').columns(('t1c1', 't1c2')).qualify_columns('t1', ('t1c1',)).sql()
     assert_equals(sql_t, ('SELECT t1.`t1c1`, `t1c2` FROM t1', None))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例9: test_having_expr_with_expr_param

 def test_having_expr_with_expr_param(self):
     q = Select()
     sql_t = q.from_table('t1').having_expr('`t1c1` = PASSWORD(?)', ('mypw',)).sql()
     assert_equals(sql_t, ('SELECT * FROM t1 HAVING `t1c1` = PASSWORD(?)', ['mypw']))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例10: test_having_expr

 def test_having_expr(self):
     q = Select()
     sql_t = q.from_table('t1').having_expr('`t1c1` = NOW()').sql()
     assert_equals(sql_t, ('SELECT * FROM t1 HAVING `t1c1` = NOW()', None))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例11: test_having_raw_value_with_param

 def test_having_raw_value_with_param(self):
     q = Select()
     sql_t = q.from_table('t1').having_raw_value('t1c1', 'PASSWORD(?)', value_params=('mypw',)).sql()
     assert_equals(sql_t, ('SELECT * FROM t1 HAVING `t1c1` = PASSWORD(?)', ['mypw']))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例12: test_having_values_dict

 def test_having_values_dict(self):
     q = Select()
     sql_t = q.from_table('t1').having_value(OrderedDict([('t1c1', 3), ('t1c2', 'string')])).sql()
     assert_equals(sql_t, ('SELECT * FROM t1 HAVING (`t1c1` = 3 AND `t1c2` = ?)', ['string']))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例13: test_select_col_callable

 def test_select_col_callable(self):
     q = Select()
     sql_t = q.from_table('t1').columns('t1c1')()
     assert_equals(sql_t, ('SELECT `t1c1` FROM t1', None))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例14: test_having_value_or_and

 def test_having_value_or_and(self):
     q = Select(having_predicate='AND')
     sql_t = q.from_table('t1').having_or().having_value('t1c1', 1).having_value('t1c1', 5).having_or().having_value('t1c1', 6).having_value('t1c1', 10).sql()
     assert_equals(sql_t, ('SELECT * FROM t1 HAVING ((`t1c1` = 1 OR `t1c1` = 5) AND (`t1c1` = 6 OR `t1c1` = 10))', None))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py

示例15: test_having_value_and_or

 def test_having_value_and_or(self):
     q = Select()
     sql_t = q.from_table('t1').having_and().having_value('t1c1', 1).having_value('t1c2', 5).having_and().having_value('t1c1', 6).having_value('t1c2', 10).sql()
     assert_equals(sql_t, ('SELECT * FROM t1 HAVING ((`t1c1` = 1 AND `t1c2` = 5) OR (`t1c1` = 6 AND `t1c2` = 10))', None))
开发者ID:lovette,项目名称:mysqlstmt,代码行数:4,代码来源:test_select.py


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