【问题标题】:How do I run a SQL query via REST against QuestDB?如何通过 REST 对 QuestDB 运行 SQL 查询?
【发布时间】:2021-02-25 16:56:24
【问题描述】:

我正在使用 Python 进行一些测试,我希望能够通过 REST 运行 SQL 查询。有没有一种简单的方法可以使用请求来运行查询,例如:

requests.get('http:myserver:9000/exec' query="select * from my_table")

【问题讨论】:

    标签: questdb


    【解决方案1】:

    如果您需要通过 Python 使用 REST,可以类似以下示例:

    import requests
    import json
    
    host = 'http://myserver:9000'
    
    sql_query = "select * from my_table limit 100"
    query_params = {'query': sql_query}
    
    try:
      response = requests.post(host + '/exec', params=query_params)
      json_response = json.loads(response.text)
      rows = json_response['dataset']
      for row in rows:
        print(row)
    except requests.exceptions.RequestException as e:
      print("Error: %s" % (e))
    

    QuestDB REST docs page 上有更多相关文档

    【讨论】:

      猜你喜欢
      • 2021-11-12
      • 2022-10-03
      • 2022-06-11
      • 2018-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多