A very micro http framework.
Project description
yhttp-pony
Pony ORM extension for yhttp.
Install
sudo apt install python3-dev libpq-dev postgresql # Postgresql
pip install yhttp-pony
Usage
This is how to use the extension.
from yhttp import Appliation, json
from yhttp.ext import pony as ponyext
from pony.orm import db_session as dbsession, PrimaryKey, Required
app = Application()
app.settings.merge('''
db:
url: postgres://postgres:postgres@localhost/foo
''')
db = ponyext.install(app)
class Foo(db.Entity):
id = PrimaryKey(int, auto=True)
title = Required(str)
@app.route()
@json
@dbsession
def get(req):
return {f.id:f.title for f in Foo.select()}
app.ready()
Command line interface
There is some command line interfaces which will be automatically added to
your application when you call ponyext.install(app)
.
myapp db create
myapp db drop
Extending db sub-command
import easycli
from yhttp.ext.pony import initialize, deinitialize
from mypackage import app # yhttp application
class InsertMockup(easycli.SubCommand):
__command__ = 'insert-mockup-data'
def __call__(self, args):
initialize(app.db, app.settings.db)
...
deinitialize(app.db)
...
db = install(app, cliarguments=[InsertMockup])
Use it as:
myapp db insert-mockup-data
Running tests
echo "ALTER USER postgres PASSWORD 'postgres'" | sudo -u postgres psql
make test
make cover
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yhttp-pony-2.4.1.tar.gz
(6.4 kB
view hashes)
Built Distribution
yhttp_pony-2.4.1-py3.8.egg
(11.4 kB
view hashes)