bottle-web2pydal-0.0.1
توضیحات
Web2py Dal integration for Bottle.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | bottle-web2pydal-0.0.1 |
| نام | bottle-web2pydal |
| نسخه کتابخانه | 0.0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Martin Mulone |
| ایمیل نویسنده | martin@tecnodoc.com.ar |
| آدرس صفحه اصلی | http://bottleweb2py.tecnodoc.com.ar |
| آدرس اینترنتی | https://pypi.org/project/bottle-web2pydal/ |
| مجوز | LGPL v3.0 |
Bottle-DAL is a plugin that integrates Web2py DAL Database Abstraction Layer
with your Bottle application. It automatically connects to a database at the
beginning of a request, passes the database handle to the route callback and
closes the connection afterwards.
To automatically detect routes that need a database connection, the plugin
searches for route callbacks that require a `db` keyword argument
(configurable) and skips routes that do not. This removes any overhead for
routes that don't need a database connection.
Usage Example::
from bottle import route, view, run, debug, install
from bottle_dal import DALPlugin, Field
def define_tables(db):
"""My tables definitions here"""
db.define_table('person',Field('name','string'))
install(DALPlugin('sqlite://storage.sqlite',
define_tables = lambda db: define_tables(db)))
@route('/')
def index(db):
""" Index Example """
if db(db.person.id>0).count()==0:
db.person.insert(name='James')
db.person.insert(name='Michael')
db.person.insert(name='Steve')
db.person.insert(name='Robert')
db.commit()
persons = db(db.person.id>0).select()
return dict(persons=persons.json())
if __name__ == '__main__':
debug(True)
run(host='localhost', port=8080)
نحوه نصب
نصب پکیج whl bottle-web2pydal-0.0.1:
pip install bottle-web2pydal-0.0.1.whl
نصب پکیج tar.gz bottle-web2pydal-0.0.1:
pip install bottle-web2pydal-0.0.1.tar.gz