Update CLAUDE.md
This commit is contained in:
@@ -14,6 +14,8 @@ DBClient is a desktop database client built with Python + PyQt6, supporting MySQ
|
|||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Key runtime dependencies: `PyQt6`, `sqlparse>=0.5.0`, `bcrypt`, `keyring`, `cryptography`.
|
||||||
|
|
||||||
**Run the application:**
|
**Run the application:**
|
||||||
```bash
|
```bash
|
||||||
python main.py
|
python main.py
|
||||||
@@ -73,7 +75,13 @@ All user data lives under `~/.dbclient/`:
|
|||||||
The `ResultTableModel` (`app/models/result_table_model.py`) is a `QAbstractTableModel` — query results should always go through it rather than populating `QTableWidget` directly.
|
The `ResultTableModel` (`app/models/result_table_model.py`) is a `QAbstractTableModel` — query results should always go through it rather than populating `QTableWidget` directly.
|
||||||
|
|
||||||
### Styling
|
### Styling
|
||||||
`resources/style.qss` is a Catppuccin Mocha dark theme applied globally at startup in `main.py`. Widget-specific overrides belong here, not as inline `setStyleSheet()` calls.
|
`resources/style.qss` is a **Catppuccin Frappé** dark theme applied globally at startup in `main.py`. Widget-specific overrides belong here, not as inline `setStyleSheet()` calls. Key palette values: base `#303446`, surface0 `#414559`, surface1 `#51576d`, text `#c6d0f5`, blue `#8caaee`, green `#a6d189`, red `#e78284`, peach `#ef9f76`, mauve `#ca9ee6`, sky `#99d1db`.
|
||||||
|
|
||||||
|
### Recent Files (`app/config/recent_files.py`)
|
||||||
|
`load_recent()` / `add_recent(path)` / `clear_recent()` persist to `~/.dbclient/recent_files.json` (max 10 entries, dead paths filtered on load). Called from MainWindow File menu.
|
||||||
|
|
||||||
|
### Settings Cascade
|
||||||
|
`PreferencesDialog` emits `settings_applied` → `MainWindow._apply_settings_to_open_tabs()` iterates workspace tabs and calls `widget.apply_settings()` on each. `SQLEditorWidget.apply_settings()` cascades to each `EditorTab`, which cascades to `CodeEditor`. Add `apply_settings()` to any new workspace widget that reads from `get_settings()`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -88,6 +96,15 @@ All four drivers have a `_where(where: dict) → (clause_str, params)` static he
|
|||||||
### Password hashing in RowDialog
|
### Password hashing in RowDialog
|
||||||
`RowDialog` detects password-like column names (via `_is_password_col()`) and hashes plain-text input with bcrypt before storing. In edit mode, leaving a password field empty omits that column from the UPDATE so the existing hash is preserved.
|
`RowDialog` detects password-like column names (via `_is_password_col()`) and hashes plain-text input with bcrypt before storing. In edit mode, leaving a password field empty omits that column from the UPDATE so the existing hash is preserved.
|
||||||
|
|
||||||
|
### ResultsPanel multi-tab architecture
|
||||||
|
`ResultsPanel` uses a `QStackedWidget` with two pages: page 0 = `QTabWidget` (result tabs), page 1 = loading spinner. Single-query results hide the tab bar; script results (`show_script_results()`) show named tabs. Each tab owns its own `ResultTableModel` + `QSortFilterProxyModel`. Export buttons operate on `_current_model()` from the active tab.
|
||||||
|
|
||||||
|
### SQL formatter
|
||||||
|
`EditorTab._format_sql()` uses `sqlparse.format(..., reindent=True, keyword_case='upper')`. Requires `sqlparse>=0.5.0` in requirements.txt.
|
||||||
|
|
||||||
|
### Column statistics worker
|
||||||
|
`_StatsWorker` in `app/ui/column_stats_dialog.py` runs `COUNT/COUNT(col)/COUNT(DISTINCT)/MIN/MAX` in one query and AVG in a second (AVG silently returns None for non-numeric columns). Both queries are quoted with `"col"` and `"table"` to handle reserved words.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Implementation Status
|
## Implementation Status
|
||||||
@@ -96,19 +113,49 @@ All four drivers have a `_where(where: dict) → (clause_str, params)` static he
|
|||||||
- Connection manager (add/edit/delete, test, color coding, keyring storage)
|
- Connection manager (add/edit/delete, test, color coding, keyring storage)
|
||||||
- Schema browser (live tree: connections → databases → tables/views/functions/procedures/triggers, search, context menus, delete connection from active node)
|
- Schema browser (live tree: connections → databases → tables/views/functions/procedures/triggers, search, context menus, delete connection from active node)
|
||||||
- SQL editor (multi-tab, syntax highlighting, line numbers, Ctrl+/ comment toggle, F5/Ctrl+Enter execute)
|
- SQL editor (multi-tab, syntax highlighting, line numbers, Ctrl+/ comment toggle, F5/Ctrl+Enter execute)
|
||||||
|
- SQL auto-complete (`app/ui/sql_completer.py`): schema-aware popup, dot-notation (schema.table, table.col), Ctrl+Space trigger
|
||||||
|
- Find/Replace bar in SQL editor (`app/ui/find_bar.py`): Ctrl+F find, Ctrl+H replace, wrap-around, case-sensitive toggle
|
||||||
|
- SQL formatter: `≡ Format` button in editor toolbar using sqlparse (reindent + uppercase keywords)
|
||||||
- Results panel (sortable `QAbstractTableModel`, export CSV/JSON/SQL INSERT, pagination, execution time)
|
- Results panel (sortable `QAbstractTableModel`, export CSV/JSON/SQL INSERT, pagination, execution time)
|
||||||
|
- Multi-result tabs: scripts with multiple SELECTs show each result in a named sub-tab within ResultsPanel
|
||||||
- Table viewer (paginated grid 50/100/All, add/edit/delete rows via dialog, WHERE filter, bcrypt password hashing)
|
- Table viewer (paginated grid 50/100/All, add/edit/delete rows via dialog, WHERE filter, bcrypt password hashing)
|
||||||
|
- Enhanced table context menu: "Filter by this value" (auto-populates WHERE filter), "Copy row as SQL INSERT"
|
||||||
|
- Column statistics dialog (`app/ui/column_stats_dialog.py`): right-click column header → async COUNT/NULL/DISTINCT/MIN/MAX/AVG
|
||||||
- Table structure view (columns, indexes, FKs, DDL with syntax highlighting, add/drop/rename column designer)
|
- Table structure view (columns, indexes, FKs, DDL with syntax highlighting, add/drop/rename column designer)
|
||||||
- Query history (auto-log with timestamp/duration/status, search, replay, persisted in `history.db`)
|
- Query history (auto-log with timestamp/duration/status, search, replay, persisted in `history.db`)
|
||||||
- All 4 DB drivers (MySQL, PostgreSQL, SQLite, MSSQL)
|
- All 4 DB drivers (MySQL, PostgreSQL, SQLite, MSSQL)
|
||||||
- Process list viewer (`app/ui/process_list.py`) with 5 s auto-refresh and kill query
|
- Process list viewer (`app/ui/process_list.py`) with 5 s auto-refresh and kill query
|
||||||
- Import CSV/JSON dialog (`app/ui/import_dialog.py`) with preview and progress bar
|
- Import CSV/JSON dialog (`app/ui/import_dialog.py`) with preview and progress bar
|
||||||
- Database dump export (`app/ui/dump_dialog.py`): schema/data/both, table selector, progress bar
|
- Database dump export (`app/ui/dump_dialog.py`): schema/data/both, table selector, progress bar
|
||||||
- Tools menu in MainWindow (Process List, Import CSV/JSON, Export Database Dump, User Management)
|
- Tools menu in MainWindow (Process List, Import CSV/JSON, Export Database Dump, User Management, Preferences)
|
||||||
|
- Preferences dialog (`app/ui/preferences_dialog.py`): Ctrl+, / Tools → Preferences; font family/size/word-wrap, page size, timeout, history limit, auto-commit; live-applies to all open editors via `settings_applied` signal
|
||||||
- PyInstaller packaging (`DBClient.spec` + `build_app.py`)
|
- PyInstaller packaging (`DBClient.spec` + `build_app.py`)
|
||||||
- User & privilege management (`app/ui/user_manager.py`): list/create/drop users, GRANT/REVOKE per-DB (MySQL + PostgreSQL)
|
- User & privilege management (`app/ui/user_manager.py`): list/create/drop users, GRANT/REVOKE per-DB (MySQL + PostgreSQL)
|
||||||
- EXPLAIN plan diagram (`app/ui/explain_view.py`): visual node tree + raw table; opened from SQL editor "🔎 Explain" button
|
- EXPLAIN plan diagram (`app/ui/explain_view.py`): visual node tree + raw table; opened from SQL editor "🔎 Explain" button
|
||||||
- Application logging (`app/utils/logger.py` + `app/ui/log_viewer.py`): rotating file logs, unhandled exception hooks, in-app log viewer (Help → View App Logs)
|
- Application logging (`app/utils/logger.py` + `app/ui/log_viewer.py`): rotating file logs, unhandled exception hooks, in-app log viewer (Help → View App Logs)
|
||||||
|
- Keyboard shortcuts dialog (`app/ui/shortcuts_dialog.py`): Help → Keyboard Shortcuts; categorised tree of all key bindings
|
||||||
|
- Tab context menus: workspace tabs (Rename/Close/Close Others/Close to Right) + SQL query tabs (Rename/Duplicate/Close/Close Others)
|
||||||
|
- Smart status bar: right-side connection indicator + 60-char cell value preview (updates on cell click)
|
||||||
|
- Connection tab coloring: workspace tab labels colored by connection profile color
|
||||||
|
- File open/save/recent: Ctrl+O open SQL file, Ctrl+S save, File → Open Recent (persisted to `~/.dbclient/recent_files.json`, max 10)
|
||||||
|
- Ctrl+W to close current workspace tab
|
||||||
|
- Catppuccin Frappé theme: full palette upgrade from Mocha; all colors updated in `resources/style.qss`, syntax highlighter, completer popup, and inline Python stylesheets
|
||||||
|
|
||||||
### Not Yet Implemented
|
### Not Yet Implemented
|
||||||
- (All planned features are now complete)
|
**High impact:**
|
||||||
|
- Auto-reconnect on dropped connection (detect broken pipe, reconnect transparently)
|
||||||
|
- Quick result filter: live filter bar above the results table (client-side, no re-query)
|
||||||
|
- SQL snippets / bookmarks: save and recall frequently used query fragments
|
||||||
|
- ERD viewer: visual entity-relationship diagram from live schema
|
||||||
|
|
||||||
|
**Medium impact:**
|
||||||
|
- Transaction panel: explicit BEGIN / COMMIT / ROLLBACK controls with in-flight indicator
|
||||||
|
- Global schema search: search across all tables/columns/procedures in a database
|
||||||
|
- Light theme: Catppuccin Latte or similar, toggle from Preferences
|
||||||
|
- Schema diff: compare two database schemas and show structural differences
|
||||||
|
|
||||||
|
**Small polish:**
|
||||||
|
- Row numbers column in results grid (virtual, not from DB)
|
||||||
|
- Connection ping indicator: periodic heartbeat dot in tab / status bar
|
||||||
|
- Frozen / pinned columns in table viewer (keep PK column always visible while scrolling)
|
||||||
|
- Keyboard navigation in RowDialog / connection dialogs (Tab order, Enter to confirm)
|
||||||
|
|||||||
Reference in New Issue
Block a user