fastapi-mongo-setup 0.3.0__tar.gz → 0.3.2__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_mongo_setup-0.3.2/PKG-INFO +82 -0
- fastapi_mongo_setup-0.3.2/README.md +68 -0
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/pyproject.toml +6 -2
- fastapi_mongo_setup-0.3.2/src/fastapi_mongo_setup.egg-info/PKG-INFO +82 -0
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/src/fastapi_mongo_setup.egg-info/SOURCES.txt +3 -0
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/src/fastapi_mongo_setup.egg-info/top_level.txt +1 -0
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/src/mongo_setup/cli.py +5 -5
- fastapi_mongo_setup-0.3.2/src/tasks/router.py +22 -0
- fastapi_mongo_setup-0.3.2/src/tasks/schemas.py +10 -0
- fastapi_mongo_setup-0.3.2/src/tasks/service.py +25 -0
- fastapi_mongo_setup-0.3.0/PKG-INFO +0 -35
- fastapi_mongo_setup-0.3.0/README.md +0 -23
- fastapi_mongo_setup-0.3.0/src/fastapi_mongo_setup.egg-info/PKG-INFO +0 -35
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/setup.cfg +0 -0
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/src/fastapi_mongo_setup.egg-info/dependency_links.txt +0 -0
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/src/fastapi_mongo_setup.egg-info/entry_points.txt +0 -0
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/src/fastapi_mongo_setup.egg-info/requires.txt +0 -0
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/src/mongo_setup/__init__.py +0 -0
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/src/utils/db.py +0 -0
- {fastapi_mongo_setup-0.3.0 → fastapi_mongo_setup-0.3.2}/src/utils/helpers.py +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastapi-mongo-setup
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: A CLI tool to auto-generate MongoDB connection boilerplates for FastAPI projects.
|
|
5
|
+
Author-email: Souvik <wbjee.souvik@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/Souvik6222/fastapi-mongo-setup
|
|
7
|
+
Project-URL: Issues, https://github.com/Souvik6222/fastapi-mongo-setup/issues
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: motor
|
|
11
|
+
Requires-Dist: python-dotenv
|
|
12
|
+
Requires-Dist: fastapi
|
|
13
|
+
Requires-Dist: pydantic-settings
|
|
14
|
+
|
|
15
|
+
# fastapi-mongo-setup 🚀
|
|
16
|
+
|
|
17
|
+
[](https://badge.fury.io/py/fastapi-mongo-setup)
|
|
18
|
+
[](https://pypi.python.org/pypi/fastapi-mongo-setup)
|
|
19
|
+
[](https://opensource.org/licenses/MIT)
|
|
20
|
+
|
|
21
|
+
**Stop writing MongoDB boilerplate for FastAPI!**
|
|
22
|
+
`fastapi-mongo-setup` is a fast, lightweight Python CLI tool that instantly scaffolds a professional, industry-standard FastAPI + MongoDB project structure. It generates async DB connections, Pydantic settings, and a fully functional CRUD router in one command.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## ⚡ Installation
|
|
27
|
+
|
|
28
|
+
Install globally or within your virtual environment:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install fastapi-mongo-setup
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 🛠️ Usage
|
|
35
|
+
|
|
36
|
+
Navigate to the root of your empty (or existing) FastAPI project and run:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
mongo-setup
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### What does this command do?
|
|
43
|
+
Instantly, it generates the following modular architecture:
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
fastapi-project/
|
|
47
|
+
├── .env # Auto-populated with MONGODB_URL and DATABASE_NAME
|
|
48
|
+
├── requirements.txt # Dependencies (fastapi, motor, pydantic-settings, etc)
|
|
49
|
+
├── main.py # FastAPI entry point with MongoDB Lifespan logic
|
|
50
|
+
└── src/
|
|
51
|
+
├── config.py # Configuration loader using Pydantic Settings
|
|
52
|
+
├── utils/ # Database core
|
|
53
|
+
│ ├── db.py # Asynchronous Motor connection manager
|
|
54
|
+
│ └── helpers.py # MongoDB ObjectId Serialization helpers
|
|
55
|
+
└── tasks/ # Complete pre-built API module
|
|
56
|
+
├── router.py # GET/POST/DELETE endpoints
|
|
57
|
+
├── schemas.py # Pydantic validation models
|
|
58
|
+
└── service.py # Database CRUD logic
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 🚀 Running Your Generated Project
|
|
62
|
+
|
|
63
|
+
Once the files are created, just install the dependencies and start the built-in demo server!
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 1. Install required packages
|
|
67
|
+
pip install -r requirements.txt
|
|
68
|
+
|
|
69
|
+
# 2. Run the server
|
|
70
|
+
python main.py
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Go to `http://localhost:8000/docs` to see your automatically generated Swagger UI with a fully functional `Tasks` API connected to your MongoDB!
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 🏗 Why this exists?
|
|
78
|
+
|
|
79
|
+
Setting up `Motor` (the async MongoDB driver) with FastAPI usually requires copy-pasting code to handle connections, lifespans, and fixing `ObjectId` serialization errors. This minimalist tool does all of that for you, providing a clean abstraction layer and a modular structure designed for scaling.
|
|
80
|
+
|
|
81
|
+
## 🤝 Contributing
|
|
82
|
+
Found a bug or want to request a feature? Feel free to open an issue or submit a pull request!
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# fastapi-mongo-setup 🚀
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/fastapi-mongo-setup)
|
|
4
|
+
[](https://pypi.python.org/pypi/fastapi-mongo-setup)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
**Stop writing MongoDB boilerplate for FastAPI!**
|
|
8
|
+
`fastapi-mongo-setup` is a fast, lightweight Python CLI tool that instantly scaffolds a professional, industry-standard FastAPI + MongoDB project structure. It generates async DB connections, Pydantic settings, and a fully functional CRUD router in one command.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## ⚡ Installation
|
|
13
|
+
|
|
14
|
+
Install globally or within your virtual environment:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install fastapi-mongo-setup
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 🛠️ Usage
|
|
21
|
+
|
|
22
|
+
Navigate to the root of your empty (or existing) FastAPI project and run:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
mongo-setup
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### What does this command do?
|
|
29
|
+
Instantly, it generates the following modular architecture:
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
fastapi-project/
|
|
33
|
+
├── .env # Auto-populated with MONGODB_URL and DATABASE_NAME
|
|
34
|
+
├── requirements.txt # Dependencies (fastapi, motor, pydantic-settings, etc)
|
|
35
|
+
├── main.py # FastAPI entry point with MongoDB Lifespan logic
|
|
36
|
+
└── src/
|
|
37
|
+
├── config.py # Configuration loader using Pydantic Settings
|
|
38
|
+
├── utils/ # Database core
|
|
39
|
+
│ ├── db.py # Asynchronous Motor connection manager
|
|
40
|
+
│ └── helpers.py # MongoDB ObjectId Serialization helpers
|
|
41
|
+
└── tasks/ # Complete pre-built API module
|
|
42
|
+
├── router.py # GET/POST/DELETE endpoints
|
|
43
|
+
├── schemas.py # Pydantic validation models
|
|
44
|
+
└── service.py # Database CRUD logic
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 🚀 Running Your Generated Project
|
|
48
|
+
|
|
49
|
+
Once the files are created, just install the dependencies and start the built-in demo server!
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# 1. Install required packages
|
|
53
|
+
pip install -r requirements.txt
|
|
54
|
+
|
|
55
|
+
# 2. Run the server
|
|
56
|
+
python main.py
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Go to `http://localhost:8000/docs` to see your automatically generated Swagger UI with a fully functional `Tasks` API connected to your MongoDB!
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 🏗 Why this exists?
|
|
64
|
+
|
|
65
|
+
Setting up `Motor` (the async MongoDB driver) with FastAPI usually requires copy-pasting code to handle connections, lifespans, and fixing `ObjectId` serialization errors. This minimalist tool does all of that for you, providing a clean abstraction layer and a modular structure designed for scaling.
|
|
66
|
+
|
|
67
|
+
## 🤝 Contributing
|
|
68
|
+
Found a bug or want to request a feature? Feel free to open an issue or submit a pull request!
|
|
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "fastapi-mongo-setup"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.2"
|
|
8
8
|
description = "A CLI tool to auto-generate MongoDB connection boilerplates for FastAPI projects."
|
|
9
9
|
authors = [
|
|
10
|
-
{name = "
|
|
10
|
+
{name = "Souvik", email = "wbjee.souvik@gmail.com"},
|
|
11
11
|
]
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
requires-python = ">=3.8"
|
|
@@ -18,6 +18,10 @@ dependencies = [
|
|
|
18
18
|
"pydantic-settings"
|
|
19
19
|
]
|
|
20
20
|
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/Souvik6222/fastapi-mongo-setup"
|
|
23
|
+
Issues = "https://github.com/Souvik6222/fastapi-mongo-setup/issues"
|
|
24
|
+
|
|
21
25
|
[project.scripts]
|
|
22
26
|
mongo-setup = "mongo_setup.cli:init"
|
|
23
27
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastapi-mongo-setup
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: A CLI tool to auto-generate MongoDB connection boilerplates for FastAPI projects.
|
|
5
|
+
Author-email: Souvik <wbjee.souvik@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/Souvik6222/fastapi-mongo-setup
|
|
7
|
+
Project-URL: Issues, https://github.com/Souvik6222/fastapi-mongo-setup/issues
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: motor
|
|
11
|
+
Requires-Dist: python-dotenv
|
|
12
|
+
Requires-Dist: fastapi
|
|
13
|
+
Requires-Dist: pydantic-settings
|
|
14
|
+
|
|
15
|
+
# fastapi-mongo-setup 🚀
|
|
16
|
+
|
|
17
|
+
[](https://badge.fury.io/py/fastapi-mongo-setup)
|
|
18
|
+
[](https://pypi.python.org/pypi/fastapi-mongo-setup)
|
|
19
|
+
[](https://opensource.org/licenses/MIT)
|
|
20
|
+
|
|
21
|
+
**Stop writing MongoDB boilerplate for FastAPI!**
|
|
22
|
+
`fastapi-mongo-setup` is a fast, lightweight Python CLI tool that instantly scaffolds a professional, industry-standard FastAPI + MongoDB project structure. It generates async DB connections, Pydantic settings, and a fully functional CRUD router in one command.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## ⚡ Installation
|
|
27
|
+
|
|
28
|
+
Install globally or within your virtual environment:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install fastapi-mongo-setup
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 🛠️ Usage
|
|
35
|
+
|
|
36
|
+
Navigate to the root of your empty (or existing) FastAPI project and run:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
mongo-setup
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### What does this command do?
|
|
43
|
+
Instantly, it generates the following modular architecture:
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
fastapi-project/
|
|
47
|
+
├── .env # Auto-populated with MONGODB_URL and DATABASE_NAME
|
|
48
|
+
├── requirements.txt # Dependencies (fastapi, motor, pydantic-settings, etc)
|
|
49
|
+
├── main.py # FastAPI entry point with MongoDB Lifespan logic
|
|
50
|
+
└── src/
|
|
51
|
+
├── config.py # Configuration loader using Pydantic Settings
|
|
52
|
+
├── utils/ # Database core
|
|
53
|
+
│ ├── db.py # Asynchronous Motor connection manager
|
|
54
|
+
│ └── helpers.py # MongoDB ObjectId Serialization helpers
|
|
55
|
+
└── tasks/ # Complete pre-built API module
|
|
56
|
+
├── router.py # GET/POST/DELETE endpoints
|
|
57
|
+
├── schemas.py # Pydantic validation models
|
|
58
|
+
└── service.py # Database CRUD logic
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 🚀 Running Your Generated Project
|
|
62
|
+
|
|
63
|
+
Once the files are created, just install the dependencies and start the built-in demo server!
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 1. Install required packages
|
|
67
|
+
pip install -r requirements.txt
|
|
68
|
+
|
|
69
|
+
# 2. Run the server
|
|
70
|
+
python main.py
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Go to `http://localhost:8000/docs` to see your automatically generated Swagger UI with a fully functional `Tasks` API connected to your MongoDB!
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 🏗 Why this exists?
|
|
78
|
+
|
|
79
|
+
Setting up `Motor` (the async MongoDB driver) with FastAPI usually requires copy-pasting code to handle connections, lifespans, and fixing `ObjectId` serialization errors. This minimalist tool does all of that for you, providing a clean abstraction layer and a modular structure designed for scaling.
|
|
80
|
+
|
|
81
|
+
## 🤝 Contributing
|
|
82
|
+
Found a bug or want to request a feature? Feel free to open an issue or submit a pull request!
|
|
@@ -205,14 +205,14 @@ if __name__ == "__main__":
|
|
|
205
205
|
env_content = f.read()
|
|
206
206
|
|
|
207
207
|
with open(env_file, "a", encoding="utf-8") as f:
|
|
208
|
-
if env_content and not env_content.endswith("
|
|
209
|
-
f.write("
|
|
208
|
+
if env_content and not env_content.endswith("\n"):
|
|
209
|
+
f.write("\n")
|
|
210
210
|
if "MONGODB_URL" not in env_content:
|
|
211
|
-
f.write("MONGODB_URL=mongodb://localhost:27017
|
|
211
|
+
f.write("MONGODB_URL=mongodb://localhost:27017\n")
|
|
212
212
|
if "DATABASE_NAME" not in env_content:
|
|
213
|
-
f.write("DATABASE_NAME=fastapi_db
|
|
213
|
+
f.write("DATABASE_NAME=fastapi_db\n")
|
|
214
214
|
if "PORT" not in env_content:
|
|
215
|
-
f.write("PORT=8000
|
|
215
|
+
f.write("PORT=8000\n")
|
|
216
216
|
|
|
217
217
|
print("Updated .env file with MongoDB environment variables.")
|
|
218
218
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from fastapi import APIRouter, HTTPException
|
|
2
|
+
from typing import List
|
|
3
|
+
from src.tasks.schemas import TaskCreate, TaskResponse
|
|
4
|
+
from src.tasks.service import TaskService
|
|
5
|
+
|
|
6
|
+
router = APIRouter(prefix="/tasks", tags=["Tasks"])
|
|
7
|
+
|
|
8
|
+
@router.post("/", response_model=TaskResponse)
|
|
9
|
+
async def create_task(task: TaskCreate):
|
|
10
|
+
created_task = await TaskService.create_task(task.model_dump())
|
|
11
|
+
return created_task
|
|
12
|
+
|
|
13
|
+
@router.get("/", response_model=List[TaskResponse])
|
|
14
|
+
async def get_tasks():
|
|
15
|
+
return await TaskService.get_all_tasks()
|
|
16
|
+
|
|
17
|
+
@router.delete("/{task_id}")
|
|
18
|
+
async def delete_task(task_id: str):
|
|
19
|
+
success = await TaskService.delete_task(task_id)
|
|
20
|
+
if not success:
|
|
21
|
+
raise HTTPException(status_code=404, detail="Task not found")
|
|
22
|
+
return {"message": "Task deleted successfully"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
class TaskCreate(BaseModel):
|
|
5
|
+
title: str = Field(..., example="Buy groceries")
|
|
6
|
+
description: Optional[str] = Field(None, example="Milk, Eggs, Bread")
|
|
7
|
+
completed: bool = False
|
|
8
|
+
|
|
9
|
+
class TaskResponse(TaskCreate):
|
|
10
|
+
id: str
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from src.utils.db import db
|
|
2
|
+
from src.utils.helpers import serialize_doc, serialize_docs
|
|
3
|
+
from bson import ObjectId
|
|
4
|
+
|
|
5
|
+
class TaskService:
|
|
6
|
+
@staticmethod
|
|
7
|
+
def get_collection():
|
|
8
|
+
return db.db["tasks"]
|
|
9
|
+
|
|
10
|
+
@staticmethod
|
|
11
|
+
async def create_task(task_data: dict) -> dict:
|
|
12
|
+
result = await TaskService.get_collection().insert_one(task_data)
|
|
13
|
+
created_task = await TaskService.get_collection().find_one({"_id": result.inserted_id})
|
|
14
|
+
return serialize_doc(created_task)
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
async def get_all_tasks() -> list:
|
|
18
|
+
cursor = TaskService.get_collection().find()
|
|
19
|
+
tasks = await cursor.to_list(length=100)
|
|
20
|
+
return serialize_docs(tasks)
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
async def delete_task(task_id: str) -> bool:
|
|
24
|
+
result = await TaskService.get_collection().delete_one({"_id": ObjectId(task_id)})
|
|
25
|
+
return result.deleted_count > 0
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: fastapi-mongo-setup
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: A CLI tool to auto-generate MongoDB connection boilerplates for FastAPI projects.
|
|
5
|
-
Author-email: Developer Name <developer@example.com>
|
|
6
|
-
Requires-Python: >=3.8
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
Requires-Dist: motor
|
|
9
|
-
Requires-Dist: python-dotenv
|
|
10
|
-
Requires-Dist: fastapi
|
|
11
|
-
Requires-Dist: pydantic-settings
|
|
12
|
-
|
|
13
|
-
# fastapi-mongo-setup
|
|
14
|
-
|
|
15
|
-
A Python CLI package that automatically creates a MongoDB connection structure for FastAPI projects.
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
pip install fastapi-mongo-setup
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
Navigate to the root of your FastAPI project and run:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
mongo-setup
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
This command will:
|
|
32
|
-
- Check if the `src/utils` directory exists (creates it if it doesn't).
|
|
33
|
-
- Generate a `src/utils/db.py` file containing an asynchronous `Database` class using `motor`. This includes `connect_to_mongodb` and `close_mongodb_connection` methods.
|
|
34
|
-
- Generate a `src/utils/helpers.py` file with a `serialize_doc` function to convert MongoDB `ObjectId` types to plain strings.
|
|
35
|
-
- Automatically append `MONGODB_URL` and `DATABASE_NAME` variables to your `.env` file.
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# fastapi-mongo-setup
|
|
2
|
-
|
|
3
|
-
A Python CLI package that automatically creates a MongoDB connection structure for FastAPI projects.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pip install fastapi-mongo-setup
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
Navigate to the root of your FastAPI project and run:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
mongo-setup
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
This command will:
|
|
20
|
-
- Check if the `src/utils` directory exists (creates it if it doesn't).
|
|
21
|
-
- Generate a `src/utils/db.py` file containing an asynchronous `Database` class using `motor`. This includes `connect_to_mongodb` and `close_mongodb_connection` methods.
|
|
22
|
-
- Generate a `src/utils/helpers.py` file with a `serialize_doc` function to convert MongoDB `ObjectId` types to plain strings.
|
|
23
|
-
- Automatically append `MONGODB_URL` and `DATABASE_NAME` variables to your `.env` file.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: fastapi-mongo-setup
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: A CLI tool to auto-generate MongoDB connection boilerplates for FastAPI projects.
|
|
5
|
-
Author-email: Developer Name <developer@example.com>
|
|
6
|
-
Requires-Python: >=3.8
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
Requires-Dist: motor
|
|
9
|
-
Requires-Dist: python-dotenv
|
|
10
|
-
Requires-Dist: fastapi
|
|
11
|
-
Requires-Dist: pydantic-settings
|
|
12
|
-
|
|
13
|
-
# fastapi-mongo-setup
|
|
14
|
-
|
|
15
|
-
A Python CLI package that automatically creates a MongoDB connection structure for FastAPI projects.
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
pip install fastapi-mongo-setup
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
Navigate to the root of your FastAPI project and run:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
mongo-setup
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
This command will:
|
|
32
|
-
- Check if the `src/utils` directory exists (creates it if it doesn't).
|
|
33
|
-
- Generate a `src/utils/db.py` file containing an asynchronous `Database` class using `motor`. This includes `connect_to_mongodb` and `close_mongodb_connection` methods.
|
|
34
|
-
- Generate a `src/utils/helpers.py` file with a `serialize_doc` function to convert MongoDB `ObjectId` types to plain strings.
|
|
35
|
-
- Automatically append `MONGODB_URL` and `DATABASE_NAME` variables to your `.env` file.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|