PgSQL integration for Bottle
Project description
Bottle-PgSQL is based on Bottle-MySQL and Bottle-sqlite. Bottle-PgSQL is a plugin that integrates PostgreSQL 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.
Results are returned as dictionaries.
Usage Example:
import bottle
import bottle_pgsql
app = bottle.Bottle()
plugin = bottle_pgsql.Plugin('dbname=db user=user password=pass')
app.install(plugin)
@app.route('/show/:<item>')
def show(item, db):
db.execute('SELECT * from items where name="%s"', (item,))
row = db.fetchone()
if row:
return template('showitem', page=row)
return HTTPError(404, "Page not found")
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
File details
Details for the file bottle-pgsql-0.2.tar.gz.
File metadata
- Download URL: bottle-pgsql-0.2.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da77928e62d011f718a64e3f9668d379828dc30ef715280d7c22160959f7c3b0
|
|
| MD5 |
faf9f35c7fd75fa822b912dc1eb3b942
|
|
| BLAKE2b-256 |
4263b49ff75d5edd7b1c5c515e475c40f6dd49e5196d3e62a5dca1c38a2179c4
|