28 lines
775 B
Python
28 lines
775 B
Python
import sqlite3
|
|
import os
|
|
|
|
# 데이터베이스 파일 경로
|
|
db_path = os.path.join(os.path.dirname(__file__), 'quant_bot.db')
|
|
|
|
# 연결 생성
|
|
conn = sqlite3.connect(db_path)
|
|
cursor = conn.cursor()
|
|
|
|
# 테이블 목록 조회
|
|
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
|
tables = cursor.fetchall()
|
|
|
|
print("Tables in database:")
|
|
for table in tables:
|
|
print(f" {table[0]}")
|
|
|
|
# 각 테이블의 구조 조회
|
|
for table in tables:
|
|
table_name = table[0]
|
|
print(f"\nStructure of {table_name}:")
|
|
cursor.execute(f"PRAGMA table_info({table_name});")
|
|
columns = cursor.fetchall()
|
|
for column in columns:
|
|
print(f" {column[1]} ({column[2]}) - nullable: {column[3]}, primary key: {column[4]}")
|
|
|
|
conn.close() |