bottle-sqlite 0.1
SQLite3 integration for Bottle.
Latest Version: 0.1.2
Bottle-sqlite is a plugin that integrates SQLite3 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:
import bottle
from bottle.ext import sqlite
app = bottle.Bottle()
plugin = sqlite.Plugin(dbfile='/tmp/test.db')
app.install(plugin)
@app.route('/show/:item')
def show(item, db):
row = db.execute('SELECT * from items where name=?', item).fetchone()
if row:
return template('showitem', page=row)
return HTTPError(404, "Page not found")
| File | Type | Py Version | Uploaded on | Size | # downloads |
|---|---|---|---|---|---|
| bottle-sqlite-0.1.tar.gz (md5) | Source | 2011-05-12 | 3KB | 771 | |
- Author: Marcel Hellkamp
- Home Page: http://bottlepy.org/docs/dev/plugins/sqlite.html
- License: MIT
- Platform: any
- Requires bottle (>=0.9)
- Categories
- Package Index Owner: defnull
- DOAP record: bottle-sqlite-0.1.xml
