Skip to main content

No project description provided

Project description

The Object API

ObjectAPI provides a concise negative-boilerplate paradigm for creating full-stack web applications with Python. It is built on top of FastAPI, SQLModel, and pydantic.

Features

  • Active record pattern for database access
  • Automatic get_by_id lookup for instance methods with route decorators
  • Automatic CRUD routes
  • Scheduled service methods
  • Managed DB sessions for service methods and for each request

Installation

pip install object-api

Usage

from object_api import App, Entity, RouterBuilder, ServiceBuilder

app = App()

class User(Entity):
    class Meta:
        service = ServiceBuilder()
        router = RouterBuilder()

        new_private = ["pass"]

    name: str
    pass: str
    age: int

    @service.servicemethod
    @classmethod
    def remove_inactive(cls):
        for user in User.get_all():
            if user.age > 100:
                user.delete()
    
    @router.route()
    def get_name(self):
        return self.name

    @router.post("/change_name")
    def change_name(self, name: str):
        self.name = name
        self.save()

app = App()

app.run()

Documentation

https://github.com/ComputaCo/object-api

License

MIT

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

object_api-0.0.1.tar.gz (11.3 kB view hashes)

Uploaded Source

Built Distribution

object_api-0.0.1-py3-none-any.whl (13.9 kB view hashes)

Uploaded Python 3

Supported by

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