-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_schema.py
More file actions
74 lines (59 loc) · 1.91 KB
/
test_schema.py
File metadata and controls
74 lines (59 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import json
import logging
import os
import sys
from dotenv import load_dotenv
# Add project to path
project_root_path = os.path.abspath(os.path.dirname(__file__))
sys.path.append(project_root_path)
# Moved imports to top (E402 fix)
from src.database.client import DatabaseClient
# Configure logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", # Line break (E501 fix)
)
logger = logging.getLogger(__name__)
# Load environment variables
load_dotenv()
def check_database_schema():
"""Check the actual database schema for available tables and columns"""
print("Initializing database client...")
db = DatabaseClient()
if not db.client:
print("Failed to initialize database client!")
return
print("Database client initialized successfully.")
# Check assets table
try:
assets = db.get_assets()
print(f"Found {len(assets)} assets in the database.")
if assets:
print("Sample asset record:")
print(json.dumps(assets[0], indent=2))
except Exception as e:
print(f"Error retrieving assets: {e}")
# Check market_data schema
try:
asset_id = 1 # Assuming BTC has ID 1
data = (
db.client.table("market_data")
.select("*")
.eq("asset_id", asset_id)
.limit(1)
.execute()
.data
)
if data:
print("\nMarket data schema:")
print("Available columns:")
for key in data[0].keys():
print(f" - {key}: {type(data[0][key]).__name__}")
print("\nSample record:")
print(json.dumps(data[0], indent=2))
else:
print("No market data records found!")
except Exception as e:
print(f"Error checking market_data schema: {e}")
if __name__ == "__main__":
check_database_schema()