Skip to main content

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.1.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file bottle-sqlite-0.1.tar.gz.

File metadata

  • Download URL: bottle-sqlite-0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bottle-sqlite-0.1.tar.gz
Algorithm Hash digest
SHA256 e33e210c6c0177b4c3b3f8c0324730b5985e629678a9167bc2ad24333203fc60
MD5 0ee58a72e4aa490700b274c61154862d
BLAKE2b-256 8b12d8a328538c20b6bb75ded0af1e20413f21cb033132d4f1601a3faca92dc9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page