Skip to main content

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 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_mysql

app = bottle.Bottle()
# dbhost is optional, default is localhost
plugin = bottle_mysql.Plugin(dbuser='user', dbpass='pass', dbname='db')
app.install(plugin)

@app.route('/show/:<tem>')
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")

Metadata

Release files for bottle-mysql 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bottle-mysql 0.3.1
File Size Uploaded
bottle-mysql-0.3.1.tar.gz 3.2 kB Details

Release files / bottle-mysql-0.3.1.tar.gz

Download URL bottle-mysql-0.3.1.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e720630560f9279efd7466f8b37af31d835252f4b69f3e9da94d08e7a2cb40c8
BLAKE2b-256 checksum
How to use checksums
10f7d6c2b67a1942786006695f00a1dec76a623e27f5a7859929ac4f4bec4842
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.1 This release

1 release file

0.3.0

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page