fastapi-sqlalchemy-ease 0.1.5__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.5/fastapi_sqlalchemy_ease.egg-info → fastapi_sqlalchemy_ease-0.1.7}/PKG-INFO +23 -8
- fastapi_sqlalchemy_ease-0.1.5/PKG-INFO → fastapi_sqlalchemy_ease-0.1.7/README.md +19 -23
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease/__init__.py +1 -1
- fastapi_sqlalchemy_ease-0.1.5/README.md → fastapi_sqlalchemy_ease-0.1.7/fastapi_sqlalchemy_ease.egg-info/PKG-INFO +38 -8
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/setup.py +3 -1
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/LICENSE +0 -0
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease/core.py +0 -0
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease/exceptions.py +0 -0
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease.egg-info/SOURCES.txt +0 -0
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease.egg-info/dependency_links.txt +0 -0
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease.egg-info/requires.txt +0 -0
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/fastapi_sqlalchemy_ease.egg-info/top_level.txt +0 -0
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/pyproject.toml +0 -0
- {fastapi_sqlalchemy_ease-0.1.5 → fastapi_sqlalchemy_ease-0.1.7}/setup.cfg +0 -0
|
@@ -1,11 +1,15 @@
|
|
|
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
|
+
Author: Hardik soni
|
|
6
|
+
Author-email: imailhr1k@gmail.com
|
|
5
7
|
Requires-Python: >=3.8
|
|
6
8
|
Description-Content-Type: text/markdown
|
|
7
9
|
License-File: LICENSE
|
|
8
10
|
Requires-Dist: sqlalchemy>=2.0.0
|
|
11
|
+
Dynamic: author
|
|
12
|
+
Dynamic: author-email
|
|
9
13
|
Dynamic: description
|
|
10
14
|
Dynamic: description-content-type
|
|
11
15
|
Dynamic: license-file
|
|
@@ -61,7 +65,7 @@ No need to import types from SQLAlchemy; use the db instance directly.
|
|
|
61
65
|
|
|
62
66
|
id = db.Column(db.Integer, primary_key=True)
|
|
63
67
|
username = db.Column(db.String, unique=True, nullable=False)
|
|
64
|
-
created_at = db.Column(db.DateTime)
|
|
68
|
+
created_at = db.Column(db.DateTime, default_server=db.func.now())
|
|
65
69
|
|
|
66
70
|
|
|
67
71
|
|
|
@@ -73,17 +77,25 @@ You can trigger table creation easily.
|
|
|
73
77
|
|
|
74
78
|
|
|
75
79
|
### 3. Database Operations in Routes
|
|
76
|
-
|
|
80
|
+
The extension provides a thread-safe db.Session for FastAPI dependencies and a Flask-like query property on models.
|
|
77
81
|
|
|
78
82
|
from fastapi import FastAPI, Depends
|
|
79
83
|
from .. import db
|
|
80
84
|
|
|
81
85
|
app = FastAPI()
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
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
|
|
87
99
|
|
|
88
100
|
|
|
89
101
|
|
|
@@ -95,7 +107,10 @@ Category - Available Attributes
|
|
|
95
107
|
Data Types - String, Integer, Float, Boolean, Text, Date, DateTime, JSON, Numeric
|
|
96
108
|
Constraints - ForeignKey, UniqueConstraint, CheckConstraint, Index
|
|
97
109
|
ORM - relationship, Table, Column
|
|
98
|
-
|
|
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
|
|
99
114
|
|
|
100
115
|
|
|
101
116
|
## ◽ Error Handling
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: fastapi-sqlalchemy-ease
|
|
3
|
-
Version: 0.1.5
|
|
4
|
-
Summary: A reusable SQLAlchemy extension for FastAPI
|
|
5
|
-
Requires-Python: >=3.8
|
|
6
|
-
Description-Content-Type: text/markdown
|
|
7
|
-
License-File: LICENSE
|
|
8
|
-
Requires-Dist: sqlalchemy>=2.0.0
|
|
9
|
-
Dynamic: description
|
|
10
|
-
Dynamic: description-content-type
|
|
11
|
-
Dynamic: license-file
|
|
12
|
-
Dynamic: requires-dist
|
|
13
|
-
Dynamic: requires-python
|
|
14
|
-
Dynamic: summary
|
|
15
|
-
|
|
16
1
|
# fastapi-sqlalchemy-ease
|
|
17
2
|
|
|
18
3
|
fastapi-sqlalchemy-ease is a singleton-based SQLAlchemy extension for FastAPI. It provides a centralized interface for database initialization, model declaration, and session management, inspired by the simplicity of Flask-SQLAlchemy.
|
|
@@ -61,7 +46,7 @@ No need to import types from SQLAlchemy; use the db instance directly.
|
|
|
61
46
|
|
|
62
47
|
id = db.Column(db.Integer, primary_key=True)
|
|
63
48
|
username = db.Column(db.String, unique=True, nullable=False)
|
|
64
|
-
created_at = db.Column(db.DateTime)
|
|
49
|
+
created_at = db.Column(db.DateTime, default_server=db.func.now())
|
|
65
50
|
|
|
66
51
|
|
|
67
52
|
|
|
@@ -73,17 +58,25 @@ You can trigger table creation easily.
|
|
|
73
58
|
|
|
74
59
|
|
|
75
60
|
### 3. Database Operations in Routes
|
|
76
|
-
|
|
61
|
+
The extension provides a thread-safe db.Session for FastAPI dependencies and a Flask-like query property on models.
|
|
77
62
|
|
|
78
63
|
from fastapi import FastAPI, Depends
|
|
79
64
|
from .. import db
|
|
80
65
|
|
|
81
66
|
app = FastAPI()
|
|
82
67
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
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
|
|
87
80
|
|
|
88
81
|
|
|
89
82
|
|
|
@@ -95,7 +88,10 @@ Category - Available Attributes
|
|
|
95
88
|
Data Types - String, Integer, Float, Boolean, Text, Date, DateTime, JSON, Numeric
|
|
96
89
|
Constraints - ForeignKey, UniqueConstraint, CheckConstraint, Index
|
|
97
90
|
ORM - relationship, Table, Column
|
|
98
|
-
|
|
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
|
|
99
95
|
|
|
100
96
|
|
|
101
97
|
## ◽ Error Handling
|
|
@@ -106,4 +102,4 @@ The library includes a DatabaseNotInitializedError. If you attempt to access db.
|
|
|
106
102
|
## 📄 License
|
|
107
103
|
Distributed under the MIT License.
|
|
108
104
|
|
|
109
|
-
--
|
|
105
|
+
--
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastapi-sqlalchemy-ease
|
|
3
|
+
Version: 0.1.7
|
|
4
|
+
Summary: A reusable SQLAlchemy extension for FastAPI
|
|
5
|
+
Author: Hardik soni
|
|
6
|
+
Author-email: imailhr1k@gmail.com
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
|
11
|
+
Dynamic: author
|
|
12
|
+
Dynamic: author-email
|
|
13
|
+
Dynamic: description
|
|
14
|
+
Dynamic: description-content-type
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
Dynamic: requires-dist
|
|
17
|
+
Dynamic: requires-python
|
|
18
|
+
Dynamic: summary
|
|
19
|
+
|
|
1
20
|
# fastapi-sqlalchemy-ease
|
|
2
21
|
|
|
3
22
|
fastapi-sqlalchemy-ease is a singleton-based SQLAlchemy extension for FastAPI. It provides a centralized interface for database initialization, model declaration, and session management, inspired by the simplicity of Flask-SQLAlchemy.
|
|
@@ -46,7 +65,7 @@ No need to import types from SQLAlchemy; use the db instance directly.
|
|
|
46
65
|
|
|
47
66
|
id = db.Column(db.Integer, primary_key=True)
|
|
48
67
|
username = db.Column(db.String, unique=True, nullable=False)
|
|
49
|
-
created_at = db.Column(db.DateTime)
|
|
68
|
+
created_at = db.Column(db.DateTime, default_server=db.func.now())
|
|
50
69
|
|
|
51
70
|
|
|
52
71
|
|
|
@@ -58,17 +77,25 @@ You can trigger table creation easily.
|
|
|
58
77
|
|
|
59
78
|
|
|
60
79
|
### 3. Database Operations in Routes
|
|
61
|
-
|
|
80
|
+
The extension provides a thread-safe db.Session for FastAPI dependencies and a Flask-like query property on models.
|
|
62
81
|
|
|
63
82
|
from fastapi import FastAPI, Depends
|
|
64
83
|
from .. import db
|
|
65
84
|
|
|
66
85
|
app = FastAPI()
|
|
67
86
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
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
|
|
72
99
|
|
|
73
100
|
|
|
74
101
|
|
|
@@ -80,7 +107,10 @@ Category - Available Attributes
|
|
|
80
107
|
Data Types - String, Integer, Float, Boolean, Text, Date, DateTime, JSON, Numeric
|
|
81
108
|
Constraints - ForeignKey, UniqueConstraint, CheckConstraint, Index
|
|
82
109
|
ORM - relationship, Table, Column
|
|
83
|
-
|
|
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
|
|
84
114
|
|
|
85
115
|
|
|
86
116
|
## ◽ Error Handling
|
|
@@ -91,4 +121,4 @@ The library includes a DatabaseNotInitializedError. If you attempt to access db.
|
|
|
91
121
|
## 📄 License
|
|
92
122
|
Distributed under the MIT License.
|
|
93
123
|
|
|
94
|
-
--
|
|
124
|
+
--
|
|
@@ -7,7 +7,9 @@ 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
|
+
author='Hardik soni',
|
|
12
|
+
author_email='imailhr1k@gmail.com',
|
|
11
13
|
description="A reusable SQLAlchemy extension for FastAPI",
|
|
12
14
|
packages=find_packages(),
|
|
13
15
|
long_description=long_description,
|
|
File without changes
|
{fastapi_sqlalchemy_ease-0.1.5 → 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
|