Skip to main content

A SQL/database library

Project description

PyPi package version Documentation Status

quma is a small SQL database library for Python and PyPy version 3.10 and higher. It maps object methods to SQL script files and supports SQLite, PostgreSQL, MySQL and MariaDB.

It also provides a simple connection pool and templating for dynamic SQL like conditional WHEREs.

Motivation

Unlike ORMs, it allows to write SQL as it was intended and to use all features the DBMS provides. As it uses plain SQL files you can fully utilize your database editor or IDE to author your queries.

If you know how to best design your DDL and already have a SELECT in your mind when data needs to be retrieved, welcome, this is for you.

It gives you back your powers you so carelessly gave away to ORMs.

Installation

pip install quma

Quick Start

The full documentation is available at https://quma.readthedocs.io

Given a directory with some SQL scripts e. g.:

/path/to/sql/scripts
├── users
│    ├── all.sql
│    └── remove.sql
└── get_admin.sql

You can access these scripts after connecting to the database:

from quma import Database

db = Database('sqlite:///:memory:', '/path/to/sql/scripts')

db.execute('CREATE TABLE users ...')

with db.cursor as cur:
    all_users = cur.users.all()

    for user in all_users:
        print(user['name'])

    cur.users.remove(id=user['id']).run()
    cur.commit()

    admin = cur.get_admin().one()

Deploy to PyPi

Install uv if not already done. Bump version number in setup.py, then:

git tag -a X.X.X -m "quma version X.X.X"
git push origin X.X.X
uv build

    # publish manually
uv publish --username <user> --token <token>

    # publish with credentials in .pypirc
    uvx uv-publish

License

quma is released under the MIT license.

Copyright © 2018-2024 ebene fünf GmbH. All rights reserved.

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

quma-0.2.1.tar.gz (43.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quma-0.2.1-py3-none-any.whl (40.1 kB view details)

Uploaded Python 3

File details

Details for the file quma-0.2.1.tar.gz.

File metadata

  • Download URL: quma-0.2.1.tar.gz
  • Upload date:
  • Size: 43.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for quma-0.2.1.tar.gz
Algorithm Hash digest
SHA256 96d3ca460ac20d4be55e3ad867fc2b01b9e11107f57aa703ed79d211bcafdaa3
MD5 df19556ae1c4079bb9a46933b7d79bc7
BLAKE2b-256 093c2a7097548ed57dcd06dfcc2c86606776463f8fdd1e76a9dab50fae038cee

See more details on using hashes here.

File details

Details for the file quma-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: quma-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 40.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for quma-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 04c894bdba0850af445e9e854448cb8034df3e950385cdd230bd5371c0628901
MD5 7a77dd1cde5357fdc2680efa2343a5a2
BLAKE2b-256 1a567e66549d8e1cbcd6e296182533b7d7b6ebc05fcb8aef90701fef4ccda2da

See more details on using hashes here.

Supported by

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