Skip to content

rivrproject/rivr-peewee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rivr-peewee

Build Status

rivr integration for the peewee database ORM.

Installation

$ pip install rivr-peewee

Usage

from rivr_peewee import Database

Creating a database

You can create a database with the DATABASE_URL environment variable using the following:

database = Database()

Or you can provide a specific environmental variable to use, and/or a default database URL:

database = Database(env='DATABASE_URL',
                    default='sqlite:///Users/kylef/database.sqlite')

You can also explicitly create a database and use it as follows:

database = Database(peewee.SqliteDatabase(':memory:'))

Building your models

The database object has a Model property to use as a base class for your models:

class User(database.Model):
    pass

Middleware

The database object itself is a rivr middleware which handles connecting and disconnecting to the database.

You can wrap a specific view in this:

app = database(router)

Or via a decorator:

@database
def view(request):
    return Response('Hello World')

Middleware Controller

You can also use rivr’s middleware controller:

from rivr.middleware import MiddlewareController

app = MiddlewareController.wrap(router,
    database,
    ExampleMiddleware(),
)

License

rivr-peewee is released under the BSD license. See LICENSE.

About

rivr integration for the peewee database ORM

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages