Ormagic

Latest version: v0.16.1

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

Scan your dependencies

Page 1 of 5

0.16.1

This release introduces support for [PostgreSQL](https://www.postgresql.org) as an alternative database, alongside improvements in flexibility and compatibility for database configuration.

New Features

- Added support for [PostgreSQL](https://www.postgresql.org) as a database option.
- To enable [PostgreSQL](https://www.postgresql.org), you need to install the appropriate driver:
bash
pip install ORMagic[postgres]

- Configure the database by setting the `ORMAGIC_DATABASE_URL` environment variable:
bash
ORMAGIC_DATABASE_URL=postgresql://user:passwordlocalhost/dbname

- Note: By default, ORMagic uses [SQLite](https://www.sqlite.org/) and requires no additional setup.

Refactoring

- Introduced the Factory Method design pattern for managing database clients.
This refactor improves code readability and scalability, enabling better support for multiple database backends.

Tests

- Added comprehensive [PostgreSQL](https://www.postgresql.org) testing for all existing test cases to ensure compatibility and reliability.
Testing now covers both [SQLite](https://www.sqlite.org/) and [PostgreSQL](https://www.postgresql.org) configurations.

This update brings significant improvements in database compatibility, internal code structure, and testing coverage, enabling developers to scale their applications with [PostgreSQL](https://www.postgresql.org). For any issues, refer to the [documentation](https://spaceshaman.github.io/ORMagic/).

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

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

Page 1 of 5

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.