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

from app.models import User

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

Update

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

Find one

await User.find(45)

Find all

await User.all()

Delete

await User.delete(45)

Advanced Query Builder

MakeFast’s MySQL integration includes a powerful QueryBuilder for advanced queries with validation and safety.

Filtering

# WHERE username = 'john'
users = await User.query().where("username", "john").get()

# WHERE age > 18 AND status = 'active'
users = await User.query().where("age", ">", 18).where("status", "active").get()

Joins

# INNER JOIN
results = await User.query().join("profiles", "users.id", "profiles.user_id").get()

# LEFT JOIN
results = await User.query().left_join("orders", "users.id", "orders.user_id").get()

Select Specific Columns

users = await User.query().select("id", "username", "email").get()

# With alias
users = await User.query().select_raw("users.id as user_id", "profiles.bio as profile_bio").get()

Ordering, Limit & Offset

users = await User.query().order_by("created_at", "DESC").limit(10).offset(20).get()

First / First Or Fail

user = await User.query().where("username", "john").first()
user = await User.query().where("username", "john").first_or_fail()

Pagination

users_page = await User.paginate(page=2, per_page=20)

Aggregations

Built-in aggregation helpers:

total_users = await User.count()
max_age = await User.max("age")
min_age = await User.min("age")
avg_age = await User.avg("age")
total_balance = await User.sum("balance")

Bulk Operations

Bulk Create

users = await User.bulk_create([
    {"username": "alice", "email": "alice@example.com"},
    {"username": "bob", "email": "bob@example.com"}
])

Get or Create

user, created = await User.get_or_create(username="john", defaults={"email": "john@example.com"})

Update or Create

user, created = await User.update_or_create(username="john", defaults={"email": "newjohn@example.com"})

Safe Raw Queries

MakeFast allows raw SQL execution with strict validation and safety:

results = await User.safe_raw_query("SELECT id, username FROM users WHERE status = %s", params=("active",))

By default, only SELECT queries are allowed unless you explicitly allow other operations.


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-2.2.6.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

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

makefast-2.2.6-py3-none-any.whl (33.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for makefast-2.2.6.tar.gz
Algorithm Hash digest
SHA256 25bb6007b3d70f8671e72fe31584d5a8bfae2f16b60b3f2cf90998d5f9c2f2ad
MD5 968498a2a51c076e4a3998644a047801
BLAKE2b-256 c6997f9b73395b992a7d51df83a9d21387332a0e78d1a69f7ecce461046d5f4d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for makefast-2.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d5e3f1e07e9f24353bce4911f20506b43318d85f85fc22c560059339b5001edf
MD5 d590d4a302c2310d935d3679d61b0222
BLAKE2b-256 44831dbc734a4134123d9c1ae8f9a4aab24f22bf10335b6f8112684637f04a10

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