a lot of fixes

This commit is contained in:
2023-06-26 11:31:47 +02:00
parent 966db6e5ad
commit f60dca6367
23 changed files with 338 additions and 45 deletions
+41
View File
@@ -0,0 +1,41 @@
import influxdb_client, os, time
from influxdb_client import InfluxDBClient, Point, WritePrecision
from influxdb_client.client.write_api import SYNCHRONOUS
from sqlalchemy import create_engine
import pandas as pd
token = "AcU0_L5vtfH-9ycHnk0txF3jgHIcWRcMOElzAVtIrAGXC0oNSjwZUzPBsWCBZHNbaJmr-9x34E1Hycow59MnQg=="
org = "econ"
url = "http://localhost:8086"
bucket="econ"
posturl='postgresql://admin:econ@localhost:15432/econ'
write_client = None
EXInit=False
EXBooksData=[]
EXTradeData=[]
BUSINESSData=[]
def get_client():
global write_client
if write_client==None:
write_client=influxdb_client.InfluxDBClient(url=url, token=token, org=org)
return write_client
def writeEXData():
db = create_engine(posturl)
conn = db.connect()
df=pd.DataFrame(EXBooksData)
df.to_sql('cx_books', con=conn, if_exists='replace',
index=False)
df=pd.DataFrame(EXTradeData)
df.to_sql("cx_trades",con=conn, if_exists='replace',
index=False)
conn.close()
def writeBusinessData():
db = create_engine(posturl)
conn = db.connect()
df=pd.DataFrame(BUSINESSData)
df.to_sql('business', con=conn, if_exists='replace',
index=False)
conn.close()