fastapi-sqlalchemy-ease 0.1.6__tar.gz → 0.1.7__tar.gz
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-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/PKG-INFO +19 -8
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/README.md +18 -7
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease/__init__.py +1 -1
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease.egg-info/PKG-INFO +19 -8
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/setup.py +1 -1
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/LICENSE +0 -0
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease/core.py +0 -0
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease/exceptions.py +0 -0
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease.egg-info/SOURCES.txt +0 -0
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease.egg-info/dependency_links.txt +0 -0
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease.egg-info/requires.txt +0 -0
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease.egg-info/top_level.txt +0 -0
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/pyproject.toml +0 -0
- {fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/setup.cfg +0 -0
|
@@ -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
|
|
@@ -46,7 +46,7 @@ No need to import types from SQLAlchemy; use the db instance directly.
|
|
|
46
46
|
|
|
47
47
|
id = db.Column(db.Integer, primary_key=True)
|
|
48
48
|
username = db.Column(db.String, unique=True, nullable=False)
|
|
49
|
-
created_at = db.Column(db.DateTime)
|
|
49
|
+
created_at = db.Column(db.DateTime, default_server=db.func.now())
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
@@ -58,17 +58,25 @@ You can trigger table creation easily.
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
### 3. Database Operations in Routes
|
|
61
|
-
|
|
61
|
+
The extension provides a thread-safe db.Session for FastAPI dependencies and a Flask-like query property on models.
|
|
62
62
|
|
|
63
63
|
from fastapi import FastAPI, Depends
|
|
64
64
|
from .. import db
|
|
65
65
|
|
|
66
66
|
app = FastAPI()
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return
|
|
68
|
+
# Best for Reads
|
|
69
|
+
@app.get("/users")
|
|
70
|
+
def get_users():
|
|
71
|
+
return User.query.all()
|
|
72
|
+
|
|
73
|
+
# Best for Writes (Auto-cleanup)
|
|
74
|
+
@app.post("/users")
|
|
75
|
+
def create_user(user_data: UserSchema, session=Depends(db.Session)):
|
|
76
|
+
user = User(**user_data.dict())
|
|
77
|
+
session.add(user)
|
|
78
|
+
session.commit()
|
|
79
|
+
return user
|
|
72
80
|
|
|
73
81
|
|
|
74
82
|
|
|
@@ -80,7 +88,10 @@ Category - Available Attributes
|
|
|
80
88
|
Data Types - String, Integer, Float, Boolean, Text, Date, DateTime, JSON, Numeric
|
|
81
89
|
Constraints - ForeignKey, UniqueConstraint, CheckConstraint, Index
|
|
82
90
|
ORM - relationship, Table, Column
|
|
83
|
-
|
|
91
|
+
Logic and Boolean operators = and_, or_, not_
|
|
92
|
+
SQL Functions (count, now, max, min, etc.) = func
|
|
93
|
+
Query Execution Utilities = select, update, delete
|
|
94
|
+
ordering = desc, asc
|
|
84
95
|
|
|
85
96
|
|
|
86
97
|
## ◽ Error Handling
|
|
@@ -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
|
|
@@ -7,7 +7,7 @@ long_description = (this_directory / "README.md").read_text()
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name='fastapi-sqlalchemy-ease',
|
|
10
|
-
version='0.1.
|
|
10
|
+
version='0.1.7',
|
|
11
11
|
author='Hardik soni',
|
|
12
12
|
author_email='imailhr1k@gmail.com',
|
|
13
13
|
description="A reusable SQLAlchemy extension for FastAPI",
|
|
File without changes
|
{fastapi_sqlalchemy_ease-0.1.6 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease/core.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|