53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
import pymysql
|
|
import os
|
|
from datetime import datetime
|
|
|
|
# DB Config
|
|
DB_HOST = 'localhost'
|
|
DB_USER = 'root'
|
|
DB_PASSWORD = '12345678'
|
|
DB_NAME = 'auto_trade_sys_new'
|
|
|
|
def connect_db():
|
|
return pymysql.connect(
|
|
host=DB_HOST,
|
|
user=DB_USER,
|
|
password=DB_PASSWORD,
|
|
database=DB_NAME,
|
|
charset='utf8mb4',
|
|
cursorclass=pymysql.cursors.DictCursor
|
|
)
|
|
|
|
def main():
|
|
try:
|
|
conn = connect_db()
|
|
cursor = conn.cursor()
|
|
|
|
print(f"Connected to {DB_NAME}")
|
|
|
|
# Search for Trade ID 3507
|
|
print("\n=== Search for Trade ID 3507 ===")
|
|
cursor.execute("SELECT * FROM trades WHERE id = 3507")
|
|
trade = cursor.fetchone()
|
|
if trade:
|
|
print(f"Found Trade 3507:")
|
|
for k, v in trade.items():
|
|
print(f" {k}: {v}")
|
|
else:
|
|
print("Trade 3507 not found in DB.")
|
|
|
|
# Check latest trades across all accounts
|
|
print("\n=== Latest 5 Trades (All Accounts) ===")
|
|
cursor.execute("SELECT id, account_id, symbol, status, pnl, pnl_percent, exit_reason, created_at FROM trades ORDER BY id DESC LIMIT 5")
|
|
trades = cursor.fetchall()
|
|
for t in trades:
|
|
print(t)
|
|
|
|
conn.close()
|
|
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|