fastapi-sqlalchemy-ease 0.1.3__tar.gz → 0.1.4__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.
Files changed (18) hide show
  1. fastapi_sqlalchemy_ease-0.1.4/PKG-INFO +109 -0
  2. fastapi_sqlalchemy_ease-0.1.4/README.md +94 -0
  3. {fastapi_sqlalchemy_ease-0.1.3 → fastapi_sqlalchemy_ease-0.1.4}/fastapi_sqlalchemy_ease/__init__.py +1 -1
  4. fastapi_sqlalchemy_ease-0.1.4/fastapi_sqlalchemy_ease.egg-info/PKG-INFO +109 -0
  5. fastapi_sqlalchemy_ease-0.1.4/setup.py +19 -0
  6. fastapi_sqlalchemy_ease-0.1.3/PKG-INFO +0 -11
  7. fastapi_sqlalchemy_ease-0.1.3/README.md +0 -16
  8. fastapi_sqlalchemy_ease-0.1.3/fastapi_sqlalchemy_ease.egg-info/PKG-INFO +0 -11
  9. fastapi_sqlalchemy_ease-0.1.3/setup.py +0 -12
  10. {fastapi_sqlalchemy_ease-0.1.3 → fastapi_sqlalchemy_ease-0.1.4}/LICENSE +0 -0
  11. {fastapi_sqlalchemy_ease-0.1.3 → fastapi_sqlalchemy_ease-0.1.4}/fastapi_sqlalchemy_ease/core.py +0 -0
  12. {fastapi_sqlalchemy_ease-0.1.3 → fastapi_sqlalchemy_ease-0.1.4}/fastapi_sqlalchemy_ease/exceptions.py +0 -0
  13. {fastapi_sqlalchemy_ease-0.1.3 → fastapi_sqlalchemy_ease-0.1.4}/fastapi_sqlalchemy_ease.egg-info/SOURCES.txt +0 -0
  14. {fastapi_sqlalchemy_ease-0.1.3 → fastapi_sqlalchemy_ease-0.1.4}/fastapi_sqlalchemy_ease.egg-info/dependency_links.txt +0 -0
  15. {fastapi_sqlalchemy_ease-0.1.3 → fastapi_sqlalchemy_ease-0.1.4}/fastapi_sqlalchemy_ease.egg-info/requires.txt +0 -0
  16. {fastapi_sqlalchemy_ease-0.1.3 → fastapi_sqlalchemy_ease-0.1.4}/fastapi_sqlalchemy_ease.egg-info/top_level.txt +0 -0
  17. {fastapi_sqlalchemy_ease-0.1.3 → fastapi_sqlalchemy_ease-0.1.4}/pyproject.toml +0 -0
  18. {fastapi_sqlalchemy_ease-0.1.3 → fastapi_sqlalchemy_ease-0.1.4}/setup.cfg +0 -0
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastapi-sqlalchemy-ease
3
+ Version: 0.1.4
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
+ # fastapi-sqlalchemy-ease
17
+
18
+ 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.
19
+
20
+ ## ◽ Key Features
21
+
22
+ - Singleton Design: Ensures a single database instance across your entire FastAPI application.
23
+
24
+ - Consolidated API: Access all SQLAlchemy types (Integer, String, ForeignKey, etc.) directly from the db object.
25
+
26
+ - Auto-Cleanup: Includes a generator-based session handler designed for FastAPI's Depends to ensure sessions are always closed.
27
+
28
+ - Built-in Lifecycle Management: Simple methods for create_all() and drop_all().
29
+
30
+
31
+ ## ◽ Installation
32
+
33
+ pip install fastapi-sqlalchemy-ease
34
+
35
+
36
+
37
+ ## ◽ Usage Guide
38
+
39
+ ### 1. Basic setup
40
+ Initialize your database instance in a centralized file (e.g. database.py).
41
+
42
+
43
+ from fastapi_sqlalchemy_ease import SQLAlchemy
44
+
45
+ '''Create the singleton instance'''
46
+ db = SQLAlchemy()
47
+
48
+ '''Initialize with your URI'''
49
+ DATABASE_URI = "sqlite:///./test.db"
50
+
51
+ '''Use connect_args={"check_same_thread": False} for SQLite'''
52
+ db.init_app(DATABASE_URI, connect_args={"check_same_thread": False})
53
+
54
+
55
+
56
+ ### 2. Defining Models
57
+ No need to import types from SQLAlchemy; use the db instance directly.
58
+
59
+ class User(db.Model):
60
+ __tablename__ = "users"
61
+
62
+ id = db.Column(db.Integer, primary_key=True)
63
+ username = db.Column(db.String, unique=True, nullable=False)
64
+ created_at = db.Column(db.DateTime)
65
+
66
+
67
+
68
+ ### 3. Creating Tables
69
+ You can trigger table creation easily.
70
+
71
+ db.create_all()
72
+
73
+
74
+
75
+ ### 3. Database Operations in Routes
76
+ Use db.Session with FastAPI's Depends to get a clean session for every request.
77
+
78
+ from fastapi import FastAPI, Depends
79
+ from .. import db
80
+
81
+ app = FastAPI()
82
+
83
+ @app.get("/users")
84
+ def read_users(session: Session = Depends(db.Session)):
85
+ users = session.query(User).all()
86
+ return users
87
+
88
+
89
+
90
+ ## ◽ Available Attributes
91
+ Your db instance provides easy access to standard SQLAlchemy types and constraints:
92
+
93
+ Category - Available Attributes
94
+
95
+ Data Types - String, Integer, Float, Boolean, Text, Date, DateTime, JSON, Numeric
96
+ Constraints - ForeignKey, UniqueConstraint, CheckConstraint, Index
97
+ ORM - relationship, Table, Column
98
+
99
+
100
+
101
+ ## ◽ Error Handling
102
+ The library includes a DatabaseNotInitializedError. If you attempt to access db.Model, db.Session, or lifecycle methods before calling db.init_app(), a clear exception will be raised to help you debug quickly.
103
+
104
+
105
+
106
+ ## 📄 License
107
+ Distributed under the MIT License.
108
+
109
+ --
@@ -0,0 +1,94 @@
1
+ # fastapi-sqlalchemy-ease
2
+
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.
4
+
5
+ ## ◽ Key Features
6
+
7
+ - Singleton Design: Ensures a single database instance across your entire FastAPI application.
8
+
9
+ - Consolidated API: Access all SQLAlchemy types (Integer, String, ForeignKey, etc.) directly from the db object.
10
+
11
+ - Auto-Cleanup: Includes a generator-based session handler designed for FastAPI's Depends to ensure sessions are always closed.
12
+
13
+ - Built-in Lifecycle Management: Simple methods for create_all() and drop_all().
14
+
15
+
16
+ ## ◽ Installation
17
+
18
+ pip install fastapi-sqlalchemy-ease
19
+
20
+
21
+
22
+ ## ◽ Usage Guide
23
+
24
+ ### 1. Basic setup
25
+ Initialize your database instance in a centralized file (e.g. database.py).
26
+
27
+
28
+ from fastapi_sqlalchemy_ease import SQLAlchemy
29
+
30
+ '''Create the singleton instance'''
31
+ db = SQLAlchemy()
32
+
33
+ '''Initialize with your URI'''
34
+ DATABASE_URI = "sqlite:///./test.db"
35
+
36
+ '''Use connect_args={"check_same_thread": False} for SQLite'''
37
+ db.init_app(DATABASE_URI, connect_args={"check_same_thread": False})
38
+
39
+
40
+
41
+ ### 2. Defining Models
42
+ No need to import types from SQLAlchemy; use the db instance directly.
43
+
44
+ class User(db.Model):
45
+ __tablename__ = "users"
46
+
47
+ id = db.Column(db.Integer, primary_key=True)
48
+ username = db.Column(db.String, unique=True, nullable=False)
49
+ created_at = db.Column(db.DateTime)
50
+
51
+
52
+
53
+ ### 3. Creating Tables
54
+ You can trigger table creation easily.
55
+
56
+ db.create_all()
57
+
58
+
59
+
60
+ ### 3. Database Operations in Routes
61
+ Use db.Session with FastAPI's Depends to get a clean session for every request.
62
+
63
+ from fastapi import FastAPI, Depends
64
+ from .. import db
65
+
66
+ app = FastAPI()
67
+
68
+ @app.get("/users")
69
+ def read_users(session: Session = Depends(db.Session)):
70
+ users = session.query(User).all()
71
+ return users
72
+
73
+
74
+
75
+ ## ◽ Available Attributes
76
+ Your db instance provides easy access to standard SQLAlchemy types and constraints:
77
+
78
+ Category - Available Attributes
79
+
80
+ Data Types - String, Integer, Float, Boolean, Text, Date, DateTime, JSON, Numeric
81
+ Constraints - ForeignKey, UniqueConstraint, CheckConstraint, Index
82
+ ORM - relationship, Table, Column
83
+
84
+
85
+
86
+ ## ◽ Error Handling
87
+ The library includes a DatabaseNotInitializedError. If you attempt to access db.Model, db.Session, or lifecycle methods before calling db.init_app(), a clear exception will be raised to help you debug quickly.
88
+
89
+
90
+
91
+ ## 📄 License
92
+ Distributed under the MIT License.
93
+
94
+ --
@@ -1,7 +1,7 @@
1
1
  from .core import SQLAlchemy
2
2
  from .exceptions import DatabaseError, DatabaseNotInitializedError
3
3
 
4
- __version__='0.1.3'
4
+ __version__='0.1.4'
5
5
 
6
6
  # when someone call: from fastapi_sqlalchemy import SQLAlchemy
7
7
  # only these things are available
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastapi-sqlalchemy-ease
3
+ Version: 0.1.4
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
+ # fastapi-sqlalchemy-ease
17
+
18
+ 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.
19
+
20
+ ## ◽ Key Features
21
+
22
+ - Singleton Design: Ensures a single database instance across your entire FastAPI application.
23
+
24
+ - Consolidated API: Access all SQLAlchemy types (Integer, String, ForeignKey, etc.) directly from the db object.
25
+
26
+ - Auto-Cleanup: Includes a generator-based session handler designed for FastAPI's Depends to ensure sessions are always closed.
27
+
28
+ - Built-in Lifecycle Management: Simple methods for create_all() and drop_all().
29
+
30
+
31
+ ## ◽ Installation
32
+
33
+ pip install fastapi-sqlalchemy-ease
34
+
35
+
36
+
37
+ ## ◽ Usage Guide
38
+
39
+ ### 1. Basic setup
40
+ Initialize your database instance in a centralized file (e.g. database.py).
41
+
42
+
43
+ from fastapi_sqlalchemy_ease import SQLAlchemy
44
+
45
+ '''Create the singleton instance'''
46
+ db = SQLAlchemy()
47
+
48
+ '''Initialize with your URI'''
49
+ DATABASE_URI = "sqlite:///./test.db"
50
+
51
+ '''Use connect_args={"check_same_thread": False} for SQLite'''
52
+ db.init_app(DATABASE_URI, connect_args={"check_same_thread": False})
53
+
54
+
55
+
56
+ ### 2. Defining Models
57
+ No need to import types from SQLAlchemy; use the db instance directly.
58
+
59
+ class User(db.Model):
60
+ __tablename__ = "users"
61
+
62
+ id = db.Column(db.Integer, primary_key=True)
63
+ username = db.Column(db.String, unique=True, nullable=False)
64
+ created_at = db.Column(db.DateTime)
65
+
66
+
67
+
68
+ ### 3. Creating Tables
69
+ You can trigger table creation easily.
70
+
71
+ db.create_all()
72
+
73
+
74
+
75
+ ### 3. Database Operations in Routes
76
+ Use db.Session with FastAPI's Depends to get a clean session for every request.
77
+
78
+ from fastapi import FastAPI, Depends
79
+ from .. import db
80
+
81
+ app = FastAPI()
82
+
83
+ @app.get("/users")
84
+ def read_users(session: Session = Depends(db.Session)):
85
+ users = session.query(User).all()
86
+ return users
87
+
88
+
89
+
90
+ ## ◽ Available Attributes
91
+ Your db instance provides easy access to standard SQLAlchemy types and constraints:
92
+
93
+ Category - Available Attributes
94
+
95
+ Data Types - String, Integer, Float, Boolean, Text, Date, DateTime, JSON, Numeric
96
+ Constraints - ForeignKey, UniqueConstraint, CheckConstraint, Index
97
+ ORM - relationship, Table, Column
98
+
99
+
100
+
101
+ ## ◽ Error Handling
102
+ The library includes a DatabaseNotInitializedError. If you attempt to access db.Model, db.Session, or lifecycle methods before calling db.init_app(), a clear exception will be raised to help you debug quickly.
103
+
104
+
105
+
106
+ ## 📄 License
107
+ Distributed under the MIT License.
108
+
109
+ --
@@ -0,0 +1,19 @@
1
+ from setuptools import setup, find_packages
2
+ from pathlib import Path
3
+
4
+ # Read the contents of your README file
5
+ this_directory = Path(__file__).parent
6
+ long_description = (this_directory / "README.md").read_text()
7
+
8
+ setup(
9
+ name='fastapi-sqlalchemy-ease',
10
+ version='0.1.4',
11
+ description="A reusable SQLAlchemy extension for FastAPI",
12
+ packages=find_packages(),
13
+ long_description=long_description,
14
+ long_description_content_type='text/markdown',
15
+ python_requires='>=3.8',
16
+ install_requires=[
17
+ 'sqlalchemy>=2.0.0'
18
+ ],
19
+ )
@@ -1,11 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: fastapi-sqlalchemy-ease
3
- Version: 0.1.3
4
- Summary: A reusable SQLAlchemy extension for FastAPI
5
- Requires-Python: >=3.8
6
- License-File: LICENSE
7
- Requires-Dist: sqlalchemy>=2.0.0
8
- Dynamic: license-file
9
- Dynamic: requires-dist
10
- Dynamic: requires-python
11
- Dynamic: summary
@@ -1,16 +0,0 @@
1
- # fastapi-sqlalchemy-ease
2
- A reusable SQLAlchemy extension for FastAPI.
3
-
4
- ## Installation
5
- ```bash
6
- pip install fastapi-sqlalchemy-ease
7
- ```
8
-
9
- ## Usage
10
- ```python
11
- from fastapi_sqlalchemy_ease import SQLAlchemy
12
-
13
- db = SQLAlchemy()
14
- DATABASE_URI = "sqlite:///site.db"
15
- db.init_app(DATABASE_URI)
16
- ```
@@ -1,11 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: fastapi-sqlalchemy-ease
3
- Version: 0.1.3
4
- Summary: A reusable SQLAlchemy extension for FastAPI
5
- Requires-Python: >=3.8
6
- License-File: LICENSE
7
- Requires-Dist: sqlalchemy>=2.0.0
8
- Dynamic: license-file
9
- Dynamic: requires-dist
10
- Dynamic: requires-python
11
- Dynamic: summary
@@ -1,12 +0,0 @@
1
- from setuptools import setup, find_packages
2
-
3
- setup(
4
- name='fastapi-sqlalchemy-ease',
5
- version='0.1.3',
6
- description="A reusable SQLAlchemy extension for FastAPI",
7
- packages=find_packages(),
8
- python_requires='>=3.8',
9
- install_requires=[
10
- 'sqlalchemy>=2.0.0'
11
- ],
12
- )