Skip to main content

No project description provided

Project description

🔥 CFlareModel

CFlareModel is a lightweight, async-first ORM for Python inspired by Laravel's Eloquent. Built with Cloudflare D1 and Cloudflare Workers in mind, it offers a fluent API, relationship management, and automatic schema introspection — all in a minimal package.

⚠️ When using CFlareModel on Cloudflare Workers, you must vendor your Python dependencies. Follow this official guide: https://github.com/cloudflare/python-workers-examples/blob/main/06-vendoring/README.md


✨ Features

  • ✅ Fluent, chainable query builder (where(), with_(), limit() etc.)
  • ⚡ Async by default — built for modern Python 3.8+
  • 🔁 Eager and lazy loading of relationships
  • 📄 Schema introspection (fillable, casts, etc.)
  • ☁️ D1-first, but pluggable with other SQL drivers

📦 Installation

pip install cflaremodel

🚀 Quickstart

from cflaremodel import Model
from cflaremodel import D1Driver

# Example User model
class User(Model):
    table = "users"
    fillable = ["name", "email"]
    casts = {"created_at": "datetime"}

async def on_fetch(request, env):
    # Setup driver
    Model.set_driver(driver=D1Driver(env.DB))
    # Query
    users = await User.query().where("email", "like", "%@example.com").get()

🧱 Defining Relationships

class Post(Model):
    table = "posts"

    async def user(self):
        return await self.belongs_to(User, "user_id")

class User(Model):
    table = "users"

    async def posts(self):
        return await self.has_many(Post, "user_id")

🧠 Schema Introspection

User.introspect({
    "name": {"type": "str"},
    "email": {"type": "str"},
    "created_at": {"type": "datetime"},
    "hidden": ["password"]
})

📜 License

GNU GPLv3 © 2025 — avltree9798

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

cflaremodel-0.1.3.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

cflaremodel-0.1.3-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file cflaremodel-0.1.3.tar.gz.

File metadata

  • Download URL: cflaremodel-0.1.3.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.5 Darwin/24.3.0

File hashes

Hashes for cflaremodel-0.1.3.tar.gz
Algorithm Hash digest
SHA256 92eda61431f4361f933e25c7b74520a3b924b2aa0ec4d9af136c74a2bf0b7a8f
MD5 f6d565d5749265892aba6a90dffe051d
BLAKE2b-256 ba4b0691d99aff5cb211512e86d112ecc81c2f404c3bb6c5d4aa2f0440395102

See more details on using hashes here.

File details

Details for the file cflaremodel-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: cflaremodel-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.5 Darwin/24.3.0

File hashes

Hashes for cflaremodel-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1d8a563c6fed50be3eabdfde55e732604c1383e201c488fed2b307a53ee08b79
MD5 8e4c8cc29848631cad8cc4e972762932
BLAKE2b-256 45832e688ca71e706e0d6b085c632a96ad6980a355cfdc801bf65eedc5fd6e5e

See more details on using hashes here.

Supported by

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