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