diff --git a/markitect/cli.py b/markitect/cli.py index 3d5643f6..4f698e76 100644 --- a/markitect/cli.py +++ b/markitect/cli.py @@ -288,25 +288,26 @@ def _show_core_system_stats(config, format): db_size = 0 db_size_human = '0 B' - # Get file counts from database + # Get file counts from database using proper API try: - conn = db_manager.get_connection() - cursor = conn.cursor() - - # Total files - cursor.execute("SELECT COUNT(*) FROM markdown_files") - total_files = cursor.fetchone()[0] + # Use execute_query method for database queries + total_files_result = db_manager.execute_query("SELECT COUNT(*) as count FROM markdown_files") + total_files = total_files_result[0]['count'] if total_files_result else 0 # Recent files (last 7 days) - cursor.execute(""" - SELECT COUNT(*) FROM markdown_files + recent_files_result = db_manager.execute_query(""" + SELECT COUNT(*) as count FROM markdown_files WHERE created_at >= datetime('now', '-7 days') """) - recent_files = cursor.fetchone()[0] + recent_files = recent_files_result[0]['count'] if recent_files_result else 0 - # Schema count - cursor.execute("SELECT COUNT(*) FROM schema_files") - schema_count = cursor.fetchone()[0] + # Schema count (table might not exist) + try: + schema_count_result = db_manager.execute_query("SELECT COUNT(*) as count FROM schema_files") + schema_count = schema_count_result[0]['count'] if schema_count_result else 0 + except Exception: + # schema_files table doesn't exist - this is okay + schema_count = 0 stats['database'] = { 'path': db_path,