Commit 8093dc38 by zhangheng

update:"taos插入"

parent 000830f0
...@@ -34,7 +34,7 @@ class TDConn: ...@@ -34,7 +34,7 @@ class TDConn:
def TD_insert(cl, table, data): def TD_insert(cl, table, data):
"""插入数据""" """插入数据"""
try: try:
sql = f"INSERT INTO {table} VALUES {data};" sql = f"INSERT INTO {table} (time, symbol, target, price) VALUES {data};"
print(sql) print(sql)
cl.execute(sql) cl.execute(sql)
except Exception as e: except Exception as e:
...@@ -89,7 +89,7 @@ def get_redis_symbol(): ...@@ -89,7 +89,7 @@ def get_redis_symbol():
def main(): def main():
nums = 40 nums = 10
cl = TDConn.TD_client() cl = TDConn.TD_client()
cl.select_db("symbol_monitor") cl.select_db("symbol_monitor")
redis_client = RedisClientLocal() redis_client = RedisClientLocal()
...@@ -117,7 +117,7 @@ def main(): ...@@ -117,7 +117,7 @@ def main():
date = item.get("date") date = item.get("date")
redis_client.con().set(f"laravel_cache:symbol-last-price:{exchange}:{symbol}", price) redis_client.con().set(f"laravel_cache:symbol-last-price:{exchange}:{symbol}", price)
if date and symbol and target and price and exchange: 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 != '': if sql != '':
TDConn.TD_insert(cl, "price_binance", 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