Ormagic

Latest version: v0.15.0

Safety actively analyzes 688007 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 4

0.15.0

This release introduces several new features, configuration options, and improvements to database connection handling, with a focus on consistency, clarity, and error handling.

New Features
* Added possibility to configure the database URL via the `ORMAGIC_DATABASE_URL` environment variable.
* Added possibility to configure the journal mode via the `ORMAGIC_JOURNAL_MODE` environment variable.

Refactoring
* Refactor connection handling using the *Factory Method* design pattern alongside `Protocol` and `ABC`, resulting in cleaner and more modular code.
* Use the `Settings` class for managing database configuration.

Bug Fixes
* Prevent invalid database connections with unsupported databases by raising exceptions.

**Full Changelog**: https://github.com/SpaceShaman/ORMagic/compare/v0.14.0...v0.15.0

0.14.0

Atomic Transactions feature has been added. This allows grouping multiple operations together in an atomic way, ensuring all operations are applied successfully or none at all.

New Features

- Introduced atomic transactions with a `transaction` context manager. This ensures that all operations within a transaction are either committed or rolled back if an error occurs.

Usage

python
from ormagic import DBModel, transaction

class User(DBModel):
name: str
age: int

with transaction():
user1 = User(name="John", age=30)
user1.save()

user2 = User(name="Alice", age=25)
user2.save()


Features and Roadmap

<!--roadmap-start-->
- [x] Define table schema using Pydantic models
- [x] Basic CRUD operations
- [x] Save data to the database
- [x] Read data from the database
- [x] Update data in the database
- [x] Delete data from the database
- [x] Relationships between tables
- [x] One-to-many
- [x] Create a tables with a foreign key
- [x] Save data with a foreign key
- [x] Read data with a foreign key
- [x] Update data with a foreign key
- [x] Delete data with a foreign key
- [X] Cascade
- [x] Set null
- [x] Restrict
- [x] Set default
- [x] No action
- [x] One-to-one
- [x] Many-to-many
- [x] Unique constraints
- [x] Remove table
- [x] Read all data from the database
- [x] Filter data and retrieve multiple records
- [x] Equal
- [x] Not equal
- [x] Greater than
- [x] Greater than or equal
- [x] Less than
- [x] Less than or equal
- [x] Like (Pattern matching with % and _)
- [x] Not like (Pattern matching with % and _)
- [x] In (List of values)
- [x] Not in (List of values)
- [x] Between (Two values)
- [x] Not between (Two values)
- [x] Q objects to combine filters (AND, OR, NOT)
- [x] Protect against SQL injection
- [x] Order by
- [x] Limit and offset
- [x] Update table schema
- [x] Add new column
- [x] Rename column
- [x] Drop column
- [x] Custom primary key
- [x] Transactions
- [ ] Functions
- [ ] Aggregate functions
- [ ] String functions
- [ ] Date and time functions
- [ ] Mathematical functions
- [ ] Control flow functions
- [ ] Migrations
- [ ] Integration with other databases
<!--roadmap-end-->

**Full Changelog**: https://github.com/SpaceShaman/ORMagic/compare/v0.13.2...v0.14.0

0.13.2

Refactoring
* Added `cursor` parameter to various methods in `models.py` to improve database operation efficiency.
* Reordered `cursor` parameter to be the first argument in functions for consistency and readability.
* Refactored table management functions in `models.py` to use context-managed cursors for improved resource handling.
* Updated `DBModel` methods to use a shared cursor for database operations.

**Full Changelog**: https://github.com/SpaceShaman/ORMagic/compare/v0.13.1...v0.13.2

0.13.1

This version focuses on improving the codebase's maintainability by refactoring database operations to use context managers.

Refactoring

- **Database Operations:**
- Updated `models.py`, `sql_utils.py`, and `table_manager.py` to use context managers for more efficient cursor management.
- Improved code clarity and reduced the risk of resource leaks.

**Full Changelog**: https://github.com/SpaceShaman/ORMagic/compare/v0.13.0...v0.13.1

0.13.0

This update introduces a major feature—support for **custom primary keys** in models, enhancing flexibility in database schema design. Alongside this, several refinements and documentation improvements have been made to ensure better maintainability and user guidance.

---

Added
- **Custom Primary Keys:**
- Implemented support for custom primary key fields in models, allowing more flexible database schema definitions.
- Updated documentation to include examples and guidelines for using custom primary keys.

- **Documentation Updates:**
- Added a new section on custom primary keys to the documentation.
- Updated the README to reflect the completion of the custom primary key feature.

Example

python
from ormagic import DBModel, DBField

class User(DBModel):
custom_id: int = DBField(primary_key=True)
name: str

User.create_table()


Features and Roadmap

<!--roadmap-start-->
- [x] Define table schema using Pydantic models
- [x] Basic CRUD operations
- [x] Save data to the database
- [x] Read data from the database
- [x] Update data in the database
- [x] Delete data from the database
- [x] Relationships between tables
- [x] One-to-many
- [x] Create a tables with a foreign key
- [x] Save data with a foreign key
- [x] Read data with a foreign key
- [x] Update data with a foreign key
- [x] Delete data with a foreign key
- [X] Cascade
- [x] Set null
- [x] Restrict
- [x] Set default
- [x] No action
- [x] One-to-one
- [x] Many-to-many
- [x] Unique constraints
- [x] Remove table
- [x] Read all data from the database
- [x] Filter data and retrieve multiple records
- [x] Equal
- [x] Not equal
- [x] Greater than
- [x] Greater than or equal
- [x] Less than
- [x] Less than or equal
- [x] Like (Pattern matching with % and _)
- [x] Not like (Pattern matching with % and _)
- [x] In (List of values)
- [x] Not in (List of values)
- [x] Between (Two values)
- [x] Not between (Two values)
- [x] Q objects to combine filters (AND, OR, NOT)
- [x] Protect against SQL injection
- [x] Order by
- [x] Limit and offset
- [x] Update table schema
- [x] Add new column
- [x] Rename column
- [x] Drop column
- [x] Custom primary key
- [ ] Functions
- [ ] Aggregate functions
- [ ] String functions
- [ ] Date and time functions
- [ ] Mathematical functions
- [ ] Control flow functions
- [ ] Bulk operations (save, update, delete)
- [ ] Migrations
- [ ] Integration with other databases

**Full Changelog**: https://github.com/SpaceShaman/ORMagic/compare/v0.12.1...v0.13.0

0.12.1

This release introduces a significant improvement to the project's documentation by migrating from the basic README-based documentation to a more robust and visually appealing setup using **Material for MkDocs**. This change enhances the overall user experience by providing a structured, easy-to-navigate, and professionally styled documentation site.

---

Added
- **Material for MkDocs Documentation:**
- Replaced the old README-based documentation with a new site built using Material for MkDocs.
- Added a clear navigation structure to help users easily find information and examples.
- Included detailed documentation sections covering installation, usage, and complex features like filtering with `Q` objects.
- Set up GitHub Actions for automatic deployment of the documentation site.

Refactoring
- **Documentation Overhaul:**
- Removed most of the old documentation from the README and streamlined it to point to the new, comprehensive documentation site.
- Enhanced formatting, readability, and structure across all documentation files using markdown extensions specific to MkDocs.

Features and Roadmap

<!--roadmap-start-->
- [x] Define table schema using Pydantic models
- [x] Basic CRUD operations
- [x] Save data to the database
- [x] Read data from the database
- [x] Update data in the database
- [x] Delete data from the database
- [x] Relationships between tables
- [x] One-to-many
- [x] Create a tables with a foreign key
- [x] Save data with a foreign key
- [x] Read data with a foreign key
- [x] Update data with a foreign key
- [x] Delete data with a foreign key
- [X] Cascade
- [x] Set null
- [x] Restrict
- [x] Set default
- [x] No action
- [x] One-to-one
- [x] Many-to-many
- [x] Unique constraints
- [x] Remove table
- [x] Read all data from the database
- [x] Filter data and retrieve multiple records
- [x] Equal
- [x] Not equal
- [x] Greater than
- [x] Greater than or equal
- [x] Less than
- [x] Less than or equal
- [x] Like (Pattern matching with % and _)
- [x] Not like (Pattern matching with % and _)
- [x] In (List of values)
- [x] Not in (List of values)
- [x] Between (Two values)
- [x] Not between (Two values)
- [x] Q objects to combine filters (AND, OR, NOT)
- [x] Protect against SQL injection
- [x] Order by
- [x] Limit and offset
- [x] Update table schema
- [x] Add new column
- [x] Rename column
- [x] Drop column
- [ ] Custom primary key
- [ ] Functions
- [ ] Aggregate functions
- [ ] String functions
- [ ] Date and time functions
- [ ] Mathematical functions
- [ ] Control flow functions
- [ ] Bulk operations (save, update, delete)
- [ ] Migrations

**Full Changelog**: https://github.com/SpaceShaman/ORMagic/compare/v0.12.0...v0.12.1

Page 1 of 4

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.