SQLite3 integration for Bottle.
Project description
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")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bottle-sqlite-0.2.0.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for bottle_sqlite-0.2.0-py3-none-any.whl
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | 33b4b7d003b84207b9d38bc94342ace9d3e83acd392eb882a1d52fc07897619d |
|
| MD5 | e8f0e8c4a30e6ed876a7460c94b61cfa |
|
| BLAKE2b-256 | 46f51cfbd2643ec28ce262966b13bcaf4887bf1d6f91e30f3d3be61092dcced0 |