-
Notifications
You must be signed in to change notification settings - Fork 0
Replace Existing Database Connection Logic with SQLAlchemy & Implement Basic Models #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Deleted the `__init__.py` file from `stat_log_db/src/stat_log_db`. - Refactored `db.py` to use the SQLAlchemy engine - Removed deprecated Database sub-classes MemDB and FileDB - Removed deprecated Connection classes - Created `modules` directory for organizing different groups of SQLAlchemy models - Created a new `BaseModel` class in `modules/base/models/base.py` for ORM mapping. - Added `Log`, `LogLevel`, and `LogType` models in `modules/log/models/` with appropriate relationships. - Introduced `Tag` model in `modules/tag/models/tag.py`. - Implemented tests for database operations in `test_db.py` and removed `test_sql_injection.py`. - Updated `tools.sh` to improve cleanup script functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces the existing database connection logic with SQLAlchemy ORM and implements basic models for a logging system. The changes modernize the codebase by moving from raw SQLite3 connections to SQLAlchemy's engine-based approach with declarative models.
Key changes:
- Replaced custom SQLite3 connection management with SQLAlchemy engine and session handling
- Implemented SQLAlchemy models for Tag, Log, LogLevel, and LogType with a BaseModel foundation
- Updated CLI to demonstrate the new ORM functionality with session-based database operations
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tools.sh | Improved cleanup logic by consolidating pycache directory removal |
| stat_log_db/tests/test_db.py | Added comprehensive tests for the new SQLAlchemy-based database functionality |
| stat_log_db/src/stat_log_db/modules//models/.py | Implemented SQLAlchemy models for Tag, Log, LogLevel, and LogType |
| stat_log_db/src/stat_log_db/modules/*/init.py | Added module exports for the new models |
| stat_log_db/src/stat_log_db/modules/base/models/base.py | Created BaseModel with common fields (id, timestamps) |
| stat_log_db/src/stat_log_db/db.py | Completely refactored to use SQLAlchemy engine instead of raw SQLite3 |
| stat_log_db/src/stat_log_db/cli.py | Updated to demonstrate new ORM functionality |
| stat_log_db/pyproject.toml | Added SQLAlchemy dependency |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Updated the Log model to properly define type_id and level_id as integers and added relationships for type and level.
No description provided.