55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
|
|
"""检查数据库中的所有表"""
|
|||
|
|
|
|||
|
|
from src.database_manager.db_manager import DatabaseManager
|
|||
|
|
|
|||
|
|
|
|||
|
|
def main():
|
|||
|
|
db = DatabaseManager()
|
|||
|
|
database = "qtrade_backtest"
|
|||
|
|
|
|||
|
|
# 获取所有表名
|
|||
|
|
tables = db.list_tables(database)
|
|||
|
|
|
|||
|
|
# 分类统计
|
|||
|
|
klines = []
|
|||
|
|
indicators = []
|
|||
|
|
business = []
|
|||
|
|
old_format = [] # 旧格式的指标表(indicator_period 格式)
|
|||
|
|
|
|||
|
|
for table_name in tables:
|
|||
|
|
if table_name.startswith("klines_"):
|
|||
|
|
klines.append(table_name)
|
|||
|
|
elif table_name.startswith("indicators_"):
|
|||
|
|
indicators.append(table_name)
|
|||
|
|
elif "_" in table_name and any(
|
|||
|
|
table_name.startswith(ind)
|
|||
|
|
for ind in ["macd", "kdj", "boll", "rsi", "ma", "ema"]
|
|||
|
|
):
|
|||
|
|
old_format.append(table_name)
|
|||
|
|
else:
|
|||
|
|
business.append(table_name)
|
|||
|
|
|
|||
|
|
print(f"总表数: {len(tables)}")
|
|||
|
|
print(f"\n=== K线表 ({len(klines)}) ===")
|
|||
|
|
for t in sorted(klines):
|
|||
|
|
print(f" {t}")
|
|||
|
|
|
|||
|
|
print(f"\n=== 指标表(新格式: indicators_period_indicator)({len(indicators)}) ===")
|
|||
|
|
for t in sorted(indicators):
|
|||
|
|
print(f" {t}")
|
|||
|
|
|
|||
|
|
print(f"\n=== 旧格式指标表(indicator_period)({len(old_format)}) ===")
|
|||
|
|
if old_format:
|
|||
|
|
for t in sorted(old_format):
|
|||
|
|
print(f" {t}")
|
|||
|
|
else:
|
|||
|
|
print(" (无)")
|
|||
|
|
|
|||
|
|
print(f"\n=== 业务表 ({len(business)}) ===")
|
|||
|
|
for t in sorted(business):
|
|||
|
|
print(f" {t}")
|
|||
|
|
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
main()
|