fastapi-sqlalchemy-ease 0.1.6__py3-none-any.whl → 0.1.7__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.
- fastapi_sqlalchemy_ease/__init__.py +1 -1
- {fastapi_sqlalchemy_ease-0.1.6.dist-info → fastapi_sqlalchemy_ease-0.1.7.dist-info}/METADATA +19 -8
- fastapi_sqlalchemy_ease-0.1.7.dist-info/RECORD +8 -0
- fastapi_sqlalchemy_ease-0.1.6.dist-info/RECORD +0 -8
- {fastapi_sqlalchemy_ease-0.1.6.dist-info → fastapi_sqlalchemy_ease-0.1.7.dist-info}/WHEEL +0 -0
- {fastapi_sqlalchemy_ease-0.1.6.dist-info → fastapi_sqlalchemy_ease-0.1.7.dist-info}/licenses/LICENSE +0 -0
- {fastapi_sqlalchemy_ease-0.1.6.dist-info → fastapi_sqlalchemy_ease-0.1.7.dist-info}/top_level.txt +0 -0
{fastapi_sqlalchemy_ease-0.1.6.dist-info → fastapi_sqlalchemy_ease-0.1.7.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi-sqlalchemy-ease
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: A reusable SQLAlchemy extension for FastAPI
|
|
5
5
|
Author: Hardik soni
|
|
6
6
|
Author-email: imailhr1k@gmail.com
|
|
@@ -65,7 +65,7 @@ No need to import types from SQLAlchemy; use the db instance directly.
|
|
|
65
65
|
|
|
66
66
|
id = db.Column(db.Integer, primary_key=True)
|
|
67
67
|
username = db.Column(db.String, unique=True, nullable=False)
|
|
68
|
-
created_at = db.Column(db.DateTime)
|
|
68
|
+
created_at = db.Column(db.DateTime, default_server=db.func.now())
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
|
|
@@ -77,17 +77,25 @@ You can trigger table creation easily.
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
### 3. Database Operations in Routes
|
|
80
|
-
|
|
80
|
+
The extension provides a thread-safe db.Session for FastAPI dependencies and a Flask-like query property on models.
|
|
81
81
|
|
|
82
82
|
from fastapi import FastAPI, Depends
|
|
83
83
|
from .. import db
|
|
84
84
|
|
|
85
85
|
app = FastAPI()
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return
|
|
87
|
+
# Best for Reads
|
|
88
|
+
@app.get("/users")
|
|
89
|
+
def get_users():
|
|
90
|
+
return User.query.all()
|
|
91
|
+
|
|
92
|
+
# Best for Writes (Auto-cleanup)
|
|
93
|
+
@app.post("/users")
|
|
94
|
+
def create_user(user_data: UserSchema, session=Depends(db.Session)):
|
|
95
|
+
user = User(**user_data.dict())
|
|
96
|
+
session.add(user)
|
|
97
|
+
session.commit()
|
|
98
|
+
return user
|
|
91
99
|
|
|
92
100
|
|
|
93
101
|
|
|
@@ -99,7 +107,10 @@ Category - Available Attributes
|
|
|
99
107
|
Data Types - String, Integer, Float, Boolean, Text, Date, DateTime, JSON, Numeric
|
|
100
108
|
Constraints - ForeignKey, UniqueConstraint, CheckConstraint, Index
|
|
101
109
|
ORM - relationship, Table, Column
|
|
102
|
-
|
|
110
|
+
Logic and Boolean operators = and_, or_, not_
|
|
111
|
+
SQL Functions (count, now, max, min, etc.) = func
|
|
112
|
+
Query Execution Utilities = select, update, delete
|
|
113
|
+
ordering = desc, asc
|
|
103
114
|
|
|
104
115
|
|
|
105
116
|
## ◽ Error Handling
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
fastapi_sqlalchemy_ease/__init__.py,sha256=B_1u8eTbj4PgoldvjW84O60UMPrFsb-1QUCq5AtiqDY,303
|
|
2
|
+
fastapi_sqlalchemy_ease/core.py,sha256=Uc6rbLLZ6gTCetkzX0a9VqVvafJQm5eyTOw_02dIM1g,4470
|
|
3
|
+
fastapi_sqlalchemy_ease/exceptions.py,sha256=6YU6mJvOGXC9D0mPH99GjMWpj21NA5jD8II7DWEcHaA,222
|
|
4
|
+
fastapi_sqlalchemy_ease-0.1.7.dist-info/licenses/LICENSE,sha256=jVnW2ZK4LFNHmDZE-xj0EyVpbHVMpwO7FcTk_We8qrA,1068
|
|
5
|
+
fastapi_sqlalchemy_ease-0.1.7.dist-info/METADATA,sha256=22IMg9_Ei84gX0Ie4ZZzCUI-vQuVNboOIuKhtEgDMZE,3662
|
|
6
|
+
fastapi_sqlalchemy_ease-0.1.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
7
|
+
fastapi_sqlalchemy_ease-0.1.7.dist-info/top_level.txt,sha256=Y9kRilavMJot8bwOZymZ0cRjiBNIzsVqx9EwvXGiq-8,24
|
|
8
|
+
fastapi_sqlalchemy_ease-0.1.7.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
fastapi_sqlalchemy_ease/__init__.py,sha256=3a9DrG-h5eU45biicv4v5pFKuG55za0iGJ_zxVJ1HxI,303
|
|
2
|
-
fastapi_sqlalchemy_ease/core.py,sha256=Uc6rbLLZ6gTCetkzX0a9VqVvafJQm5eyTOw_02dIM1g,4470
|
|
3
|
-
fastapi_sqlalchemy_ease/exceptions.py,sha256=6YU6mJvOGXC9D0mPH99GjMWpj21NA5jD8II7DWEcHaA,222
|
|
4
|
-
fastapi_sqlalchemy_ease-0.1.6.dist-info/licenses/LICENSE,sha256=jVnW2ZK4LFNHmDZE-xj0EyVpbHVMpwO7FcTk_We8qrA,1068
|
|
5
|
-
fastapi_sqlalchemy_ease-0.1.6.dist-info/METADATA,sha256=9XIZhq-4CMSPUeqDfgQy2t79bALyiQ0JBWWZo_xWnvw,3236
|
|
6
|
-
fastapi_sqlalchemy_ease-0.1.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
7
|
-
fastapi_sqlalchemy_ease-0.1.6.dist-info/top_level.txt,sha256=Y9kRilavMJot8bwOZymZ0cRjiBNIzsVqx9EwvXGiq-8,24
|
|
8
|
-
fastapi_sqlalchemy_ease-0.1.6.dist-info/RECORD,,
|
|
File without changes
|
{fastapi_sqlalchemy_ease-0.1.6.dist-info → fastapi_sqlalchemy_ease-0.1.7.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{fastapi_sqlalchemy_ease-0.1.6.dist-info → fastapi_sqlalchemy_ease-0.1.7.dist-info}/top_level.txt
RENAMED
|
File without changes
|