當前位置: 首頁>>代碼示例>>Python>>正文


Python SqlSelect.parse方法代碼示例

本文整理匯總了Python中sql_select.SqlSelect.parse方法的典型用法代碼示例。如果您正苦於以下問題:Python SqlSelect.parse方法的具體用法?Python SqlSelect.parse怎麽用?Python SqlSelect.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sql_select.SqlSelect的用法示例。


在下文中一共展示了SqlSelect.parse方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_group_by_case_when

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_group_by_case_when(self):
     sql_select = SqlSelect.parse(
         "SELECT * FROM symbol GROUP BY CASE WHEN price > 10 THEN 'high' ELSE 'low' END AS hl")
     self.assertEqual(['hl'], sql_select.group_by.keys())
     self.assertEqual(stypes.Case, type(sql_select.group_by['hl']))
     sql_select = SqlSelect.parse(
         "SELECT * FROM symbol GROUP BY ( CASE WHEN price > 10 THEN 'high' ELSE 'low' END) AS hl")
     self.assertEqual(['hl'], sql_select.group_by.keys())
     self.assertEqual(stypes.Case, type(sql_select.group_by['hl']))
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:11,代碼來源:sql_select_test.py

示例2: test_not_like

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_not_like(self):
     sql_select = SqlSelect.parse("SELECT * FROM symbol WHERE a NOT LIKE 'abc%'")
     comparison = sql_select.where.tokens[-1]
     self.assertEqual(stypes.Comparison, type(comparison))
     self.assertEqual('NOT LIKE', comparison.operator)
     self.assertEqual('a', str(comparison.left))
     self.assertEqual("'abc%'", str(comparison.right))
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:9,代碼來源:sql_select_test.py

示例3: test_bigger_than_function_expression

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_bigger_than_function_expression(self):
     sql_select = SqlSelect.parse("SELECT * FROM symbol WHERE a > now() - INTERVAL '5 DAYS'")
     comparison = sql_select.where.tokens[-1]
     self.assertEqual(stypes.Comparison, type(comparison))
     self.assertEqual('>', comparison.operator)
     self.assertEqual('a', str(comparison.left))
     self.assertEqual("now() - eval_datetime('INTERVAL', '5 DAYS')", str(comparison.right))
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:9,代碼來源:sql_select_test.py

示例4: test_not_in

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_not_in(self):
     sql_select = SqlSelect.parse('SELECT * FROM symbol WHERE a NOT IN (1,2,3)')
     comparison = sql_select.where.tokens[-1]
     self.assertEqual(stypes.Comparison, type(comparison))
     self.assertEqual('NOT IN', comparison.operator)
     self.assertEqual('a', str(comparison.left))
     self.assertEqual('(1,2,3)', str(comparison.right))
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:9,代碼來源:sql_select_test.py

示例5: test_is

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_is(self):
     sql_select = SqlSelect.parse('SELECT * FROM symbol WHERE a IS NULL')
     comparison = sql_select.where.tokens[-1]
     self.assertEqual(stypes.Comparison, type(comparison))
     self.assertEqual('IS', comparison.operator)
     self.assertEqual('a', str(comparison.left))
     self.assertEqual('NULL', str(comparison.right))
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:9,代碼來源:sql_select_test.py

示例6: test_in

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_in(self):
     sql_select = SqlSelect.parse("SELECT * FROM symbol WHERE symbol IN ('AAPL', 'GOOG')")
     comparison = sql_select.where.tokens[-1]
     self.assertEqual(stypes.Comparison, type(comparison))
     self.assertEqual('IN', comparison.operator)
     self.assertEqual('symbol', str(comparison.left))
     self.assertEqual("('AAPL', 'GOOG')", str(comparison.right))
開發者ID:coofucoo,項目名稱:es-monitor,代碼行數:9,代碼來源:sql_select_test.py

示例7: test_bigger_than

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_bigger_than(self):
     sql_select = SqlSelect.parse('SELECT * FROM symbol WHERE a > 0')
     comparison = sql_select.where.tokens[-1]
     self.assertEqual(stypes.Comparison, type(comparison))
     self.assertEqual('>', comparison.operator)
     self.assertEqual('a', str(comparison.left))
     self.assertEqual('0', str(comparison.right))
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:9,代碼來源:sql_select_test.py

示例8: test_projection_is_wildcard

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_projection_is_wildcard(self):
     sql_select = SqlSelect.parse('SELECT * FROM symbol')
     self.assertEqual(['*'], sql_select.projections.keys())
     self.assertEqual(ttypes.Wildcard, sql_select.projections['*'].ttype)
     self.assertIsNone(sql_select.where)
     self.assertEqual(dict(), sql_select.group_by)
     self.assertEqual([], sql_select.order_by)
     self.assertEqual([], sql_select.having)
     self.assertIsNone(sql_select.limit)
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:11,代碼來源:sql_select_test.py

示例9: test_projection_is_expression_without_function

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_projection_is_expression_without_function(self):
     sql_select = SqlSelect.parse('SELECT a/2 AS abc FROM symbol')
     self.assertEqual(['abc'], sql_select.projections.keys())
     self.assertEqual(stypes.Expression, type(sql_select.projections['abc']))
     self.assertEqual('a/2', str(sql_select.projections['abc']))
     self.assertIsNone(sql_select.where)
     self.assertEqual(dict(), sql_select.group_by)
     self.assertEqual([], sql_select.order_by)
     self.assertEqual([], sql_select.having)
     self.assertIsNone(sql_select.limit)
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:12,代碼來源:sql_select_test.py

示例10: test_projection_is_named

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_projection_is_named(self):
     sql_select = SqlSelect.parse('SELECT COUNT(*) AS abc FROM symbol')
     self.assertEqual(['abc'], sql_select.projections.keys())
     self.assertEqual(stypes.Function, type(sql_select.projections['abc']))
     self.assertEqual('COUNT', sql_select.projections['abc'].get_name())
     self.assertEqual(ttypes.Wildcard, sql_select.projections['abc'].get_parameters()[0].ttype)
     self.assertIsNone(sql_select.where)
     self.assertEqual(dict(), sql_select.group_by)
     self.assertEqual([], sql_select.order_by)
     self.assertEqual([], sql_select.having)
     self.assertIsNone(sql_select.limit)
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:13,代碼來源:sql_select_test.py

示例11: test_group_by_function

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_group_by_function(self):
     sql_select = SqlSelect.parse("SELECT * FROM symbol GROUP BY date_trunc('minute', ts) AS m")
     self.assertEqual(['m'], sql_select.group_by.keys())
     self.assertEqual(stypes.Function, type(sql_select.group_by['m']))
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:6,代碼來源:sql_select_test.py

示例12: test_limit

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_limit(self):
     sql_select = SqlSelect.parse('SELECT * FROM symbol LIMIT 1')
     self.assertEqual(1, sql_select.limit)
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:5,代碼來源:sql_select_test.py

示例13: test_join_one_field

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_join_one_field(self):
     sql_select = SqlSelect.parse(
         'SELECT * FROM quote JOIN matched_symbols ON quote.symbol = matched_symbols.symbol')
     self.assertEqual('matched_symbols', sql_select.join_table)
     self.assertTrue(len(sql_select.join_conditions) > 0)
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:7,代碼來源:sql_select_test.py

示例14: test_order_by_desc

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_order_by_desc(self):
     sql_select = SqlSelect.parse("SELECT * FROM symbol ORDER BY name   DESC")
     self.assertEqual(1, len(sql_select.order_by))
     self.assertEqual('name   DESC', str(sql_select.order_by[0]))
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:6,代碼來源:sql_select_test.py

示例15: test_single_year_month

# 需要導入模塊: from sql_select import SqlSelect [as 別名]
# 或者: from sql_select.SqlSelect import parse [as 別名]
 def test_single_year_month(self):
     sql_select = SqlSelect.parse("SELECT * FROM index('symbol-%Y-%m', '2015-06') AS my_table GROUP BY name")
     self.assertEqual('symbol-2015-06', sql_select.from_indices)
開發者ID:gitter-badger,項目名稱:es-monitor,代碼行數:5,代碼來源:sql_select_test.py


注:本文中的sql_select.SqlSelect.parse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。