Commit 8c9f001
authored
Replace databases with sqlalchemy async (#1515)
* Replace databases library with SQLAlchemy async API
Migrate the project from the databases library to using SQLAlchemy's native async API directly.
- ormar/connection.py: DatabaseConnection class that wraps AsyncEngine
- ormar/query_executor.py: QueryExecutor class for database operations
- ormar/transaction.py: Transaction management with savepoint support
- Updated OrmarConfig, QuerySet, Model, and related files to use new async patterns
- Simplified SQLite pragma handling
- Updated all dialect access patterns
- Updated test files to use DatabaseConnection and async drivers
- Changed DDL operations to use async engine with run_sync()
* Fix connection management and transaction handling
Fixes critical connection pool exhaustion and transaction handling issues.
Key changes:
- Removed auto-commit from QueryExecutor
- Use engine.begin() for auto-commit connections
- Added connection pool limits (pool_size=5, max_overflow=10)
- Fixed transaction connection reuse
* fix all tests to pass
* fix all tests to pass in all backends
* update gitignore
* add no cover to sqlite test in lifespan for other engines related part
* quick and ugly docs src fix to pass test docs workflow
* remove unused substitue_backend_pool_for_sqlite and duplicate code in model.py
* simplify getting the query executor to avoid code duplication
* simplify prefetch related query
* add back force rollback to signals that was not working with databases, remove unused cleanup, double check force rollback on db without transaction is working too
* add more tests for transactions, ensure sqlite transaction rollback with nested transactions
* fix depth check and change to value error to avoid swallowing exceptions in transactions tests
* remove engine from docs sources as its optional and we handle db creation and drop separately
* fix example too
* updates the lines references after the docs changes and fixes
* updates the documentation to reflect the new DatabaseConnection dependency and migration to async SQLAlchemy. Add migration example and update dependencies for async support.
* add relases and bump version to 0.22.0
* bump version to 0.22.0
* bump poetry version in workflows
* fix benchmarks not connected error
* bump pytest-asyncio version to 1.2.0 and update benchmarks to not use event loop fixture
* bump pytest-cov
* restore benchmark fixture decorator
* revert pytest-asyncio to check pipeline
* check 1.2 version of pytest-asyncio
* Revert "check 1.2 version of pytest-asyncio"
This reverts commit e964f44.
* Reapply "check 1.2 version of pytest-asyncio"
This reverts commit 437b956.
* check if new fixture is messing up the coverage
* Revert "check if new fixture is messing up the coverage"
This reverts commit 0353e49.
* Revert "Reapply "check 1.2 version of pytest-asyncio""
This reverts commit e71cd75.
* update benchmark mode to simulation and python 3.12
* update benchmarks remove options
* update benchmarks restore part of the options
* update benchmarks restore part of the options
* Revert "update benchmarks restore part of the options"
This reverts commit 4917ebc.
* Revert "update benchmarks restore part of the options"
This reverts commit 2fe38dc.
* Revert "update benchmarks remove options"
This reverts commit 5fa3950.
* Revert "update benchmark mode to simulation and python 3.12"
This reverts commit 80e7ff3.
* update benchmarks restore part of the options
* run on codspeed-macro instead of ubuntu-latest
* revert to ubuntu-latest for benchmarks and instrumentation mode
* avoid begin if not in transaction, asyncio sleep every 100 rows for better performance1 parent 95b9a97 commit 8c9f001
109 files changed
Lines changed: 2845 additions & 1771 deletions
File tree
- .github/workflows
- benchmarks
- docs_src
- aggregations
- fastapi/mypy
- fields
- models
- queries
- relations
- select_columns
- signals
- docs
- fastapi
- fields
- models
- queries
- relations
- examples
- ormar
- databases
- fields
- models
- helpers
- queryset
- actions
- queries
- scripts
- tests
- test_databases
- test_hashes
- test_inheritance_and_pydantic_generation
- test_meta_constraints
- test_model_definition
- pks_and_fks
- test_queries
- test_relations
- test_signals
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
53 | 64 | | |
54 | 65 | | |
55 | 66 | | |
| |||
79 | 90 | | |
80 | 91 | | |
81 | 92 | | |
82 | | - | |
| 93 | + | |
83 | 94 | | |
84 | 95 | | |
85 | 96 | | |
| 97 | + | |
| 98 | + | |
86 | 99 | | |
87 | 100 | | |
88 | 101 | | |
89 | | - | |
| 102 | + | |
90 | 103 | | |
91 | 104 | | |
92 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
0 commit comments