🍞 Loaf
So bland yet so good!™
Effortlessly access your SQL servers and procedures, plus some other utilities.
Install
$ pip install loaf
Examples
Importing Into Your Project
from loaf import Loaf
Setting Up Credentials
# Setup your credentials with a single line.
loaf = Loaf(port=6969, db="pizzeria")
# Or load your credentials from a file.
loaf = Loaf(file="creds.ini")
# Or use a local SQLite file instead.
loaf = Loaf(file="pizzeria.db")
Executing Queries
# Make queries easily.
toppings = loaf.query("SELECT * from toppings")
# Load your quieries directly from files.
clients = loaf.query(file="getHappyClients.sql")
# Prevent disasters by executing multiple queries.
pepperoni_id, client_name = loaf.multi([
"SELECT id FROM toppings WHERE name='Pepperoni'",
"SELECT name FROM clients WHERE id=6"
])
Printing
# Display info using built-in tables!
loaf.print(pepperoni_id)
loaf.print(client_name)
loaf.print(toppings)
┏━━━━┓
┃ id ┃
┡━━━━┩
│ 1 │
└────┘
┏━━━━━━━━━━━┓
┃ name ┃
┡━━━━━━━━━━━┩
│ 'Alfonso' │
└───────────┘
┏━━━━┳━━━━━━━━━━━━━┳━━━━━━━┓
┃ id ┃ name ┃ price ┃
┡━━━━╇━━━━━━━━━━━━━╇━━━━━━━┩
│ 1 │ 'Pepperoni' │ 1.49 │
│ 2 │ 'Mushrooms' │ 1.99 │
│ 3 │ 'Onions' │ 0.99 │
└────┴─────────────┴───────┘
Data Manipulation
# Manipulate your data with dictionaries, as God intended.
for topping in toppings:
print(topping['name'])
Pepperoni
Mushrooms
Onions
Utilities
# Not lazy enough? Try some of the pre-built queires.
# Equivalent of: SELECT name FROM client WHERE name='Marco' LIMIT 1
result = loaf.select("name", "clients", "name='Marco'", limit=1)
# Get all values from a table.
result = loaf.all("toppings")
# Got stored procedures? No problemo!
result = loaf.call("ProcedureFindClient", 1)
⚠️ Syntax for the package has changed heavily since version 0.2.0, if your project depends on Loaf and is using an inferior version, I heavily suggest that you use the previous stable version:
$ pip install loaf==0.1.30
Metadata
Release files for loaf 0.2.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| loaf-0.2.21.tar.gz | 6.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| loaf-0.2.21-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / loaf-0.2.21.tar.gz
| Download URL | loaf-0.2.21.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f38edf8283a86494020136ea9e3c722d3eead0d75736962eb8b7b53aeae8f40d
|
|
BLAKE2b-256 checksum How to use checksums |
0e52b41d06d52001a95b4997d90262d9b9053d682bd129c04d68fba7f8bfa4d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / loaf-0.2.21-py3-none-any.whl
| Download URL | loaf-0.2.21-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e73b4e9c2d18902a94e3ea1ea4ec37828808acf8e9b3eb72f12c7bf7146f6c8
|
|
BLAKE2b-256 checksum How to use checksums |
6f1ed080af669bec925b35154b8b376ff2615a49f3071d65ff6d4eb19b6387a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Security for loaf 0.2.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.