Skip to main content

FastAPI CLI Library

Project description

MakeFast - FastAPI CLI Manager

Python 3.8+ License: MIT

Welcome to MakeFast, a FastAPI CLI library designed to streamline your development workflow. With MakeFast, you can efficiently manage your projects, and focus on writing high-quality code.

Table of Contents

Installation

To install MakeFast, simply run the following command in your terminal:

pip install makefast

After the run this command to make the project template:

makefast init

Finally, run the:

pip install -r requirements.txt

To run the project, you can run the uvicorn command:

uvicorn main:app --port 8000 --reload

Commands

Project Creation

Command Description Options
makefast init Initializes a new project

Route Generation

Command Description Options
makefast create-route ROUTE_NAME Generates a new route --model MODEL_NAME, --request_scheme REQUEST_NAME, --response_scheme RESPONSE_NAME

Model Generation

Command Description Options
makefast create-model MODEL_NAME Generates a new model --table TABLE_NAME, --collection COLLECTION_NAME

Schema Generation

Command Description Options
makefast create-schema SCHEMA_NAME Generates a new schema

Enum Generation

Command Description Options
makefast create-enum ENUM_NAME Generates a new enum --type str

Database Configuration

Makefast provide the easiest way to configure the database and using them. By default makefast has 2 databases which is MySql and MongoDB.

MySQL

To initiate MySQL, add below lines on main.py file as necessary.

from fastapi import FastAPI
from makefast.database import MySQLDatabaseInit

app = FastAPI()

MySQLDatabaseInit.init(app)

MongoDB

To initiate MongoDB, add below lines on main.py file as necessary.

from fastapi import FastAPI
from makefast.database import MongoDBDatabaseInit

app = FastAPI()

MongoDBDatabaseInit.init(app)

Database CRUD operations

Makefast offers default functions for CRUD operations. Before using these, you need to create a model that corresponds to the MySQL table or MongoDB collection.

Create

To create a new record, use the Model.create method, passing in the desired attributes. This method is asynchronous and returns a response that typically contains information about the newly created record.

from app.models import User

create_response = await User.create(**{
    "username": "usertest",
    "email": "test@example.com",
    "password": "test123",
})

Update

To update an existing record, specify the ID and the fields to modify using Model.update. This example updates the name field of the user with ID 45.

from app.models import User

await User.update(45, **{
    "name": "New name"
})

Find one

To retrieve a single record, use Model.find. This function typically returns the first record matching the criteria or, if no criteria are specified, an arbitrary record.

from app.models import User

await User.find(45)

Find all

To retrieve all the records, use the Model.all method, which returns a collection of records.

from app.models import User

await User.all()

Delete

To delete a record by their ID, use the Model.delete method. Here, we remove the user with an ID of 45.

from app.models import User

await User.delete(45)

Contributing

Contributions are welcome! To contribute to MakeFast, follow these steps:

  1. Fork the repository
  2. Create a new branch
  3. Make changes and commit them
  4. Create a pull request

License

MakeFast is licensed under the MIT License. See LICENSE for details.

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

makefast-1.0.4.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

makefast-1.0.4-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file makefast-1.0.4.tar.gz.

File metadata

  • Download URL: makefast-1.0.4.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for makefast-1.0.4.tar.gz
Algorithm Hash digest
SHA256 77bb8f9a73d9778676df0955fff0b94d8a9b9539ca1d3b02b04962cbbca426a7
MD5 dddbf2d593fa768c72b72ac58228f281
BLAKE2b-256 f7d0acdd03b6e5b39f9106f79f1fd66b052ccbce72e51a7d9e011ba6e1b09dde

See more details on using hashes here.

File details

Details for the file makefast-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: makefast-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for makefast-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 560dd93c613891ae2aa56e7d3d8bb907a72889ba2e37d1618d4d7d81e04562e8
MD5 b21e7da336207985d8aead45b6c8163d
BLAKE2b-256 5d3b46c60a3fd84a6b9b5012c2e6643e8be32d8205c5d651e086fb8918c545e4

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