Powered by Tachyonic Project Luxon Framework v0.0.0

Luxon Framework for rapid application development. (luxon)


Database API

Luxon provides a standard PEP-0249 compliant Database interface currently supporting MySQL and SQLite3.

Pooling is automatically provided for databases with exception to SQLite3. SQLite3 is not threadsafe natively so only locking is provided. Keep in mind SQLite3 will be far slower than others due to the locking mechanisem, unless no threads are used. Recently SQLite has support for threading but requires additional dependencies.

The goal here is to support args as either list or dict. All param style formats are supported as per PEP-0249.

paramstyle Meaning
qmark Question mark style, e.g. …WHERE name=?
numeric Numeric, positional style, e.g. …WHERE name=:1
named Named style, e.g. …WHERE name=:name
format ANSI C printf format codes, e.g. …WHERE name=%s
pyformat Python extended format codes, e.g. …WHERE name=%(name)s
You need to ensure you provide the correct args object for the format used. e.g. qmark cannot be used when providing a dict. This is because qmark has no reference to the dict key.

During iteration or fetch methods all return lists of rows containing dict. The dict keys are equal to the column names used in the database.

Configuration should be done via settings.ini


# Type is either 'sqlite3' or 'mysql'

# Relevent to both MySQL and SQLite3

# Relevant to only MYSQL

Example Usage

from luxon import db

with db() as conn:
    res = conn.execute("SELECT.....", [args])
    for row in res:

    # or alternatively:
    with db.cursor() as crsr:
        res = crsr.fetchall()