
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
A flexible and dynamic CRUD (Create, Read, Update, Delete) operations library for FastAPI applications with MySQL database support.
pip install smart-api-bridge
from fastapi import FastAPI
from api_bridge import APIBridge
app = FastAPI()
# Configure database connection
db_config = {
"host": "localhost",
"port": 3306,
"database": "mydb",
"user": "username",
"password": "password@123",
}
# Initialize APIBridge
api_bridge = APIBridge(db_config)
# Create FastAPI app
app = FastAPI()
app.include_router(api_bridge.router)
# Run with uvicorn
# uvicorn main:app --reload
Method | Endpoint | Description |
---|---|---|
GET | /api/test | Test database connection |
GET | /api/{table_name} | Fetch all records (supports pagination) |
POST | /api/{table_name} | Insert a new record |
PUT | /api/{table_name}/{record_id} | Update an existing record |
PATCH | /api/{table_name}/{record_id} | Partially update a record |
DELETE | /api/{table_name}/{record_id} | Soft delete a record |
DELETE | /api/{table_name}/{record_id}/hard | Permanently delete a record |
Manage products, categories, inventory, and orders using dynamic CRUD operations:
import os
from fastapi import FastAPI
from api_bridge import APIBridge
app = FastAPI(title="E-commerce API")
# Load database config
db_config = {
"host": os.getenv("DB_HOST", "localhost"),
"port": int(os.getenv("DB_PORT", 3306)),
"database": os.getenv("DB_NAME", "ecommerce"),
"user": os.getenv("DB_USER", "user"),
"password": os.getenv("DB_PASS", "password"),
}
# Initialize APIBridge
api_bridge = APIBridge(db_config)
app.include_router(api_bridge.router)
@app.get("/")
def read_root():
return {"message": "E-commerce API ready"}
Manage blog posts, pages, users, and media files:
from fastapi import FastAPI
from api_bridge import
from fastapi.middleware.cors import CORSMiddleware
import os
app = FastAPI(title="CMS API")
# Configure CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Load database config
db_config = {
"host": os.getenv("DB_HOST", "localhost"),
"port": int(os.getenv("DB_PORT", 3306)),
"database": os.getenv("DB_NAME", "cms"),
"user": os.getenv("DB_USER", "user"),
"password": os.getenv("DB_PASS", "password"),
}
# Initialize APIBridge
api_bridge = APIBridge(db_config)
app.include_router(api_bridge.router)
@app.get("/")
def read_root():
return {"message": "CMS API ready"}
Prepare Your Package Structure:
smart-api-bridge/
├── smart_api_bridge/
│ ├── __init__.py
│ ├── db.py
│ ├── router.py
├── setup.py
├── README.md
├── LICENSE
└── requirements.txt
Test Your Package Locally:
pip install -e .
Build Your Package:
pip install build
python -m build
Upload to PyPI Test:
pip install twine
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
Test Your Package from TestPyPI:
pip install --index-url https://test.pypi.org/simple/ smart-api-bridge
Upload to PyPI:
twine upload dist/*
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A FastAPI-based CRUD API generator for MySQL databases
We found that smart-api-bridge demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.