LinkDesk/backend/check_indexes.py

36 lines
1007 B
Python

#!/usr/bin/env python3
"""
Script to check current database indexes
"""
import sqlite3
def check_current_indexes():
conn = sqlite3.connect('database.db')
cursor = conn.cursor()
# Get all non-system indexes
cursor.execute("SELECT name FROM sqlite_master WHERE type='index' AND name NOT LIKE 'sqlite_%' ORDER BY name;")
indexes = cursor.fetchall()
print('Current indexes:')
for idx in indexes:
print(f' {idx[0]}')
# Get index details
cursor.execute(f"PRAGMA index_info('{idx[0]}')")
info = cursor.fetchall()
if info:
columns = [col[2] for col in info]
print(f' Columns: {", ".join(columns)}')
# Get table info for tasks table
print('\nTasks table structure:')
cursor.execute("PRAGMA table_info(tasks)")
columns = cursor.fetchall()
for col in columns:
print(f' {col[1]} ({col[2]})')
conn.close()
if __name__ == "__main__":
check_current_indexes()