async-easy-model 0.2.3__py3-none-any.whl → 0.2.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- async_easy_model/__init__.py +6 -3
- async_easy_model/auto_relationships.py +132 -2
- async_easy_model/model.py +516 -367
- async_easy_model/visualization.py +619 -0
- {async_easy_model-0.2.3.dist-info → async_easy_model-0.2.5.dist-info}/METADATA +85 -1
- async_easy_model-0.2.5.dist-info/RECORD +11 -0
- async_easy_model-0.2.3.dist-info/RECORD +0 -10
- {async_easy_model-0.2.3.dist-info → async_easy_model-0.2.5.dist-info}/LICENSE +0 -0
- {async_easy_model-0.2.3.dist-info → async_easy_model-0.2.5.dist-info}/WHEEL +0 -0
- {async_easy_model-0.2.3.dist-info → async_easy_model-0.2.5.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: async-easy-model
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.5
|
4
4
|
Summary: A simplified SQLModel-based ORM for async database operations
|
5
5
|
Home-page: https://github.com/puntorigen/easy-model
|
6
6
|
Author: Pablo Schaffner
|
@@ -59,6 +59,7 @@ A simplified SQLModel-based ORM for async database operations in Python. async-e
|
|
59
59
|
- 📝 Type hints for better IDE support
|
60
60
|
- 🕒 Automatic `id`, `created_at` and `updated_at` fields provided by default
|
61
61
|
- 🔄 Automatic schema migrations for evolving database models
|
62
|
+
- 📊 Visualization of database schema using Mermaid ER diagrams
|
62
63
|
|
63
64
|
## Installation
|
64
65
|
|
@@ -250,6 +251,89 @@ deleted_count = await User.delete({"is_active": False})
|
|
250
251
|
await Post.delete({"user": {"username": "john_doe"}, "is_published": False})
|
251
252
|
```
|
252
253
|
|
254
|
+
## Database Schema Visualization
|
255
|
+
|
256
|
+
The package includes a `ModelVisualizer` class that makes it easy to generate Entity-Relationship (ER) diagrams for your database models using Mermaid syntax.
|
257
|
+
|
258
|
+
```python
|
259
|
+
from async_easy_model import EasyModel, init_db, db_config, ModelVisualizer
|
260
|
+
|
261
|
+
# Initialize your models and database
|
262
|
+
await init_db()
|
263
|
+
|
264
|
+
# Create a visualizer
|
265
|
+
visualizer = ModelVisualizer()
|
266
|
+
|
267
|
+
# Generate a Mermaid ER diagram
|
268
|
+
er_diagram = visualizer.mermaid()
|
269
|
+
print(er_diagram)
|
270
|
+
|
271
|
+
# Generate a shareable link to view the diagram online
|
272
|
+
er_link = visualizer.mermaid_link()
|
273
|
+
print(er_link)
|
274
|
+
|
275
|
+
# Customize the diagram title
|
276
|
+
visualizer.set_title("My Project Database Schema")
|
277
|
+
custom_diagram = visualizer.mermaid()
|
278
|
+
```
|
279
|
+
|
280
|
+
### Example Mermaid ER Diagram Output
|
281
|
+
|
282
|
+
```mermaid
|
283
|
+
---
|
284
|
+
title: EasyModel Table Schemas
|
285
|
+
config:
|
286
|
+
layout: elk
|
287
|
+
---
|
288
|
+
erDiagram
|
289
|
+
author {
|
290
|
+
number id PK
|
291
|
+
string name "required"
|
292
|
+
string email
|
293
|
+
}
|
294
|
+
book {
|
295
|
+
number id PK
|
296
|
+
string title "required"
|
297
|
+
number author_id FK
|
298
|
+
string isbn
|
299
|
+
number published_year
|
300
|
+
author author "virtual"
|
301
|
+
tag[] tags "virtual"
|
302
|
+
}
|
303
|
+
tag {
|
304
|
+
number id PK
|
305
|
+
string name "required"
|
306
|
+
book[] books "virtual"
|
307
|
+
}
|
308
|
+
book_tag {
|
309
|
+
number id PK
|
310
|
+
number book_id FK "required"
|
311
|
+
number tag_id FK "required"
|
312
|
+
book book "virtual"
|
313
|
+
tag tag "virtual"
|
314
|
+
}
|
315
|
+
review {
|
316
|
+
number id PK
|
317
|
+
number book_id FK "required"
|
318
|
+
number rating "required"
|
319
|
+
string comment
|
320
|
+
string reviewer_name "required"
|
321
|
+
book book "virtual"
|
322
|
+
}
|
323
|
+
book ||--o{ author : "author_id"
|
324
|
+
book_tag ||--o{ book : "book_id"
|
325
|
+
book_tag ||--o{ tag : "tag_id"
|
326
|
+
book }o--o{ tag : "many-to-many"
|
327
|
+
review ||--o{ book : "book_id"
|
328
|
+
```
|
329
|
+
|
330
|
+
The diagram automatically:
|
331
|
+
- Shows all tables with their fields and data types
|
332
|
+
- Identifies primary keys (PK) and foreign keys (FK)
|
333
|
+
- Shows required fields and virtual relationships
|
334
|
+
- Visualizes relationships between tables with proper cardinality
|
335
|
+
- Properly handles many-to-many relationships
|
336
|
+
|
253
337
|
## Convenient Query Methods
|
254
338
|
|
255
339
|
async-easy-model provides simplified methods for common query patterns:
|
@@ -0,0 +1,11 @@
|
|
1
|
+
async_easy_model/__init__.py,sha256=cpv45_jab9WbuemZehABoXL64VZ19R-L4-UOAbj8sls,1739
|
2
|
+
async_easy_model/auto_relationships.py,sha256=V2LAzNi7y-keFk4C_m-byVRM-k_7nL5HEy9Ig3nEdq8,27756
|
3
|
+
async_easy_model/migrations.py,sha256=rYDGCGlruSugAmPfdIF2-uhyG6UvC_2qbF3BXJ084qI,17803
|
4
|
+
async_easy_model/model.py,sha256=Vq6NTUThuEKy_CVLAb6Dy5pcDjbBr49qgamTQj5GtZ0,63284
|
5
|
+
async_easy_model/relationships.py,sha256=vR5BsJpGaDcecCcNlg9-ouZfxFXFQv5kOyiXhKp_T7A,3286
|
6
|
+
async_easy_model/visualization.py,sha256=VdW89D103sF7nnB1BG3EnGcID1HF-1TVr_U0iaOuFjA,27355
|
7
|
+
async_easy_model-0.2.5.dist-info/LICENSE,sha256=uwDkl6oHbRltW7vYKNc4doJyhtwhyrSNFFlPpKATwLE,1072
|
8
|
+
async_easy_model-0.2.5.dist-info/METADATA,sha256=G6Ol1O_uihhCchSJnf0dCHEP0G3NEl4Nd_pBJwOoKiA,12866
|
9
|
+
async_easy_model-0.2.5.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
10
|
+
async_easy_model-0.2.5.dist-info/top_level.txt,sha256=e5_47sGmJnyxz2msfwU6C316EqmrSd9RGIYwZyWx68E,17
|
11
|
+
async_easy_model-0.2.5.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
async_easy_model/__init__.py,sha256=u1yerriPm93E_uXcK9r-y7wcMOV1F4t-KjKEooCaiIA,1642
|
2
|
-
async_easy_model/auto_relationships.py,sha256=VetxcrOdKGGSImTiysRFR8PSOSlo50RqnVG95CLe8Jg,22433
|
3
|
-
async_easy_model/migrations.py,sha256=rYDGCGlruSugAmPfdIF2-uhyG6UvC_2qbF3BXJ084qI,17803
|
4
|
-
async_easy_model/model.py,sha256=G-0htjy78Nae5HdNE2dMGV8Z8s-rUNRTUANcKArxrDM,57852
|
5
|
-
async_easy_model/relationships.py,sha256=vR5BsJpGaDcecCcNlg9-ouZfxFXFQv5kOyiXhKp_T7A,3286
|
6
|
-
async_easy_model-0.2.3.dist-info/LICENSE,sha256=uwDkl6oHbRltW7vYKNc4doJyhtwhyrSNFFlPpKATwLE,1072
|
7
|
-
async_easy_model-0.2.3.dist-info/METADATA,sha256=SZJy5Ozs7Jn-J3qVTiVB637IGza-5C6hdet_dPocM3I,10720
|
8
|
-
async_easy_model-0.2.3.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
9
|
-
async_easy_model-0.2.3.dist-info/top_level.txt,sha256=e5_47sGmJnyxz2msfwU6C316EqmrSd9RGIYwZyWx68E,17
|
10
|
-
async_easy_model-0.2.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|