写入数据

插入新数据

用户也可以通过 sql API 插入数据

python

  1. from greptime import query
  2. @copr(returns=["affected_rows"])
  3. def insert() -> vector[i32]:
  4. return query().sql("insert into monitor(host, ts, cpu, memory) values('localhost',1667446807000, 15.3, 66.6)")

json

  1. {
  2. "code": 0,
  3. "output": [
  4. {
  5. "records": {
  6. "schema": {
  7. "column_schemas": [
  8. {
  9. "name": "rows",
  10. "data_type": "Int32"
  11. }
  12. ]
  13. },
  14. "rows": [
  15. [
  16. 1
  17. ]
  18. ]
  19. }
  20. }
  21. ],
  22. "execution_time_ms": 4
  23. }