优化表名,将binance_kline改为bn_futures_kline_1d

This commit is contained in:
yhydev
2026-01-14 13:36:14 +08:00
parent a821ed39fb
commit a271af3ae9

View File

@@ -185,11 +185,11 @@ def create_table(conn):
"""
# 先检查并删除旧表,然后重新创建
drop_table_query = """
DROP TABLE IF EXISTS binance_kline;
DROP TABLE IF EXISTS bn_futures_kline_1d;
"""
create_table_query = """
CREATE TABLE binance_kline (
CREATE TABLE bn_futures_kline_1d (
id SERIAL PRIMARY KEY,
symbol VARCHAR(20) NOT NULL,
open_time TIMESTAMP NOT NULL,
@@ -213,7 +213,7 @@ def create_table(conn):
cur.execute(drop_table_query)
cur.execute(create_table_query)
conn.commit()
logger.info("Created binance_kline table with updated schema")
logger.info("Created bn_futures_kline_1d table with updated schema")
except psycopg2.Error as e:
logger.error(f"Failed to create table: {e}")
conn.rollback()
@@ -258,7 +258,7 @@ def insert_data(conn, df):
# 构建查询条件使用VALUES列表
values_list = ','.join([f"('{symbol}', '{open_time}')" for symbol, open_time in batch_pairs])
check_query = f"""
SELECT symbol, open_time FROM binance_kline
SELECT symbol, open_time FROM bn_futures_kline_1d
WHERE (symbol, open_time) IN ({values_list})
"""
@@ -307,7 +307,7 @@ def insert_data(conn, df):
# 4. 准备插入数据
insert_query = """
INSERT INTO binance_kline (
INSERT INTO bn_futures_kline_1d (
symbol, open_time, high, low, open, close, volume,
close_time, quote_asset_volume, number_of_trades,
taker_buy_base_asset_volume, taker_buy_quote_asset_volume, ignore