Skip to content

ei-grad/muffin-peewee

 
 

Repository files navigation

Muffin Peewee

Muffin Peewee -- Peewee ORM integration to Muffin framework.

Build Status

image

image

Donate

Requirements

  • python >= 3.3

Installation

Muffin Peewee should be installed using pip: :

pip install muffin-peewee

Usage

Add muffin_peewee to PLUGINS in your Muffin Application configuration.

Or install it manually like this: :

db = muffin_peewee.Plugin(**{'options': 'here'})

app = muffin.Application('test')
app.install(db)

Options

PEEWEE_CONNECTION -- connection string to your database (sqlite:///db.sqlite)

PEEWEE_CONNECTION_PARAMS -- Additional params for connection ({})

PEEWEE_CONNECTION_MANUAL -- Doesn't manage db connections automatically

PEEWEE_MIGRATIONS_ENABLED -- enable migrations (True)

PEEWEE_MIGRATIONS_PATH -- path to migration folder (migrations)

Queries

@app.ps.peewee.register
class Test(peewee.Model):
    data = peewee.CharField()


@app.register
def view(request):
    return [t.data for t in Test.select()]

Manage connections

# Set configuration option `PEEWEE_CONNECTION_MANUAL` to True

# Use context manager
@app.register
def view(request):
    with (yield from app.ps.peewee.manage()):
        # Work with db
        # ...

Migrations

Create migrations: :

$ muffin example:app create [NAME]

Run migrations: :

$ muffin example:app migrate [NAME]

Load/Dump data to CSV

Dump table test to CSV file: :

$ muffin example:app csv_dump test

Load data from CSV file to table `test`: :

$ muffin example:app csv_load test

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin-peewee/issues

Contributing

Development of Muffin Peewee happens at: https://github.com/klen/muffin-peewee

Contributors

  • klen (Kirill Klenov)

License

Licensed under a MIT license.

About

Peewee integration to Muffin framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 94.9%
  • Makefile 5.0%
  • Vim Script 0.1%