Package: apistar-peewee-orm
API Star Peewee ORMVersion:0.3.6Status:Production/StableAuthor:José Antonio Perdiguero LópezPeewee integration for API Star.FeaturesThis library provides:Event hooks to handleconnectionsandcommit/rollbackbehavior based on exceptions in your views.Migrationssupport with a command-line interface to interact with them.Quick startInstall API Star Peewee ORM:pipinstallapistar-peewee-ormCreate an API Star application adding components and event hooks:fromapistarimportAppfromapistar_peewee_ormimportPeeweeDatabaseComponent,PeeweeTransactionHookroutes=[]components=[PeeweeDatabaseComponent(url='sqlite://'),]event_hooks=[PeeweeTransactionHook(),]app=App(routes=routes,components=components,event_hooks=event_hooks)Your models now should inherit from a base model defined in this library:importpeeweefromapistar_peewee_ormimportModelclassPuppyModel(Model):name=peewee.CharField()Full ExampleimporttypingimportpeeweefromapistarimportApp,http,Route,types,validatorsfromapistar_peewee_ormimportModel,PeeweeDatabaseComponent,PeeweeTransactionHookclassPuppyModel(Model):name=peewee.CharField()classPuppyType(types.Type):id=validators.Integer(allow_null=True,default=None)name=validators.String()deflist_puppies()->typing.List[PuppyType]:return[PuppyType(puppy)forpuppyinPuppyModel.select()]defcreate_puppy(puppy:PuppyType,raise_exception:http.QueryParam)->http.JSONResponse:ifraise_exception:raiseExceptionmodel=PuppyModel.create(**puppy)returnhttp.JSONResponse(PuppyType(model),status_code=201)routes=[Route('/puppy/','POST',create_puppy),Route('/puppy/','GET',list_puppies),]components=[PeeweeDatabaseComponent(url='sqlite://'),]event_hooks=[PeeweeTransactionHook(),]app=App(routes=routes,components=components,event_hooks=event_hooks)CLI ApplicationAn application will be installed along with this library to provide full support for migrations and some other features
of Peewee and API Star.$ apistar-peewee-orm --help

usage: apistar-peewee-orm [-h] [-s SETTINGS] [-q | -v] [--dry-run]
                          {status,upgrade,downgrade,merge,create} ... [app]

positional arguments:
  app                   API Star application path
                        (<package>.<module>:<variable>)

optional arguments:
  -h, --help            show this help message and exit
  -s SETTINGS, --settings SETTINGS
                        Module or object with Clinner settings in format
                        "package.module[:Object]"
  -q, --quiet           Quiet mode. No standard output other than executed
                        application
  -v, --verbose         Verbose level (This option is additive)
  --dry-run             Dry run. Skip commands execution, useful to check
                        which commands will be executed and execution order

Commands:
  {status,upgrade,downgrade,merge,create}
    status              Database migrations and models status.
    upgrade             Run database migrations sequentially.
    downgrade           Rollback database migrations sequentially.
    merge               Merge all migrations into a single one.
    create              Create a new migration. If a module is provided then
                        the migration will be automatically generated,
                        otherwise the migration will be empty.