Skip to main content

A CLI tool to auto-generate MongoDB connection boilerplates for FastAPI projects.

Project description

fastapi-mongo-setup

A Python CLI package that automatically creates a MongoDB connection structure for FastAPI projects.

Installation

pip install fastapi-mongo-setup

Usage

Navigate to the root of your FastAPI project and run:

mongo-setup

This command will:

  • Check if the src/utils directory exists (creates it if it doesn't).
  • Generate a src/utils/db.py file containing an asynchronous Database class using motor. This includes connect_to_mongodb and close_mongodb_connection methods.
  • Generate a src/utils/helpers.py file with a serialize_doc function to convert MongoDB ObjectId types to plain strings.
  • Automatically append MONGODB_URL and DATABASE_NAME variables to your .env file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_mongo_setup-0.3.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_mongo_setup-0.3.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_mongo_setup-0.3.0.tar.gz.

File metadata

  • Download URL: fastapi_mongo_setup-0.3.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for fastapi_mongo_setup-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d56696d0c290b254ae68e2d2c7d33a07494557b5ff3e023078881ee1fa81cfff
MD5 2ae45cbd0f6d8728f640b088ccb5319f
BLAKE2b-256 528be1ccf00374a9b1dbadd361a0b77af8da273b4221ccf44ba1c6d52a03322b

See more details on using hashes here.

File details

Details for the file fastapi_mongo_setup-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_mongo_setup-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abb6d95a7041198bddd5c2ab4f7848b9d14437105150d19d8e044777c650c79d
MD5 f629fd3db32cc2872d0cdda9667334c0
BLAKE2b-256 518b57509be864d590935bb8e1a302c107cacc63e7981e308f5acc852751446f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page