Commit 8093dc38 by zhangheng

update:"taos插入"

parent 000830f0
......@@ -34,7 +34,7 @@ class TDConn:
def TD_insert(cl, table, data):
"""插入数据"""
try:
sql = f"INSERT INTO {table} VALUES {data};"
sql = f"INSERT INTO {table} (time, symbol, target, price) VALUES {data};"
print(sql)
cl.execute(sql)
except Exception as e:
......@@ -89,7 +89,7 @@ def get_redis_symbol():
def main():
nums = 40
nums = 10
cl = TDConn.TD_client()
cl.select_db("symbol_monitor")
redis_client = RedisClientLocal()
......@@ -117,7 +117,7 @@ def main():
date = item.get("date")
redis_client.con().set(f"laravel_cache:symbol-last-price:{exchange}:{symbol}", price)
if date and symbol and target and price and exchange:
sql += f'({date}, "{symbol}", "{target}", {price}, "{exchange}") '
sql += f'({date}, "{symbol}", "{target}", {price}) '
# 插入数据
if sql != '':
TDConn.TD_insert(cl, "price_binance", sql)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment