Bottle-MySQL is a plugin that integrates MySQL 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 pymydb 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_pymysql
app = bottle.Bottle()
# dbhost is optional, default is localhost
plugin = bottle_pymysql.Plugin(dbuser='user', dbpass='pass', dbname='db')
app.install(plugin)
@app.route('/show/:<tem>')
def show(item, pymydb):
pymydb.execute('SELECT * from items where name="%s"', (item,))
row = pymydb.fetchone()
if row:
return template('showitem', page=row)
return HTTPError(404, "Page not found")
Metadata
Release files for bottle-pymysql 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bottle-pymysql-0.1.4.tar.gz | 5.6 kB | Details |
Release files / bottle-pymysql-0.1.4.tar.gz
| Download URL | bottle-pymysql-0.1.4.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04a9aca61ade7443d4d0b39224cff63b90a9bc5cf21d5acef590fd4f62dbacef
|
|
BLAKE2b-256 checksum How to use checksums |
06a8c22c1bb3706b9876d514177c937d0ccb4ee27e2b584d0dd2310349d4d4db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|