35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
|
|
import os
|
|
import sys
|
|
from sqlalchemy import create_engine, text, inspect
|
|
|
|
# Database connection
|
|
DB_USER = os.getenv('DB_USER', 'root')
|
|
DB_PASSWORD = os.getenv('DB_PASSWORD', '12345678')
|
|
DB_HOST = os.getenv('DB_HOST', 'localhost')
|
|
DB_PORT = os.getenv('DB_PORT', '3306')
|
|
DB_NAME = 'auto_trade_sys_new'
|
|
|
|
DATABASE_URL = f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
|
|
|
|
def inspect_db():
|
|
try:
|
|
engine = create_engine(DATABASE_URL)
|
|
inspector = inspect(engine)
|
|
table_names = inspector.get_table_names()
|
|
print(f"Tables: {table_names}")
|
|
|
|
if 'trading_config' in table_names:
|
|
columns = inspector.get_columns('trading_config')
|
|
print("\nColumns in trading_config:")
|
|
for col in columns:
|
|
print(f" - {col['name']} ({col['type']})")
|
|
else:
|
|
print("\ntrading_config table NOT found!")
|
|
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
inspect_db()
|