Effortlessly access your SQL servers and procedures, plus some other utilities!
Project description
๐ 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
loaf-0.2.9.tar.gz
(6.0 kB
view details)
Built Distribution
loaf-0.2.9-py3-none-any.whl
(8.0 kB
view details)
File details
Details for the file loaf-0.2.9.tar.gz
.
File metadata
- Download URL: loaf-0.2.9.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e8ce67263e50d6711b9886acc1e32fc3ca35d0de8c0510d3f5340b9fdb4123d |
|
MD5 | 7475c8d883899c5d46a5b9925b53a54e |
|
BLAKE2b-256 | fb2b30efc7031821ac6626eaec9e957c62b4cc67c02ee0c9db7a1755c41a1c7a |
File details
Details for the file loaf-0.2.9-py3-none-any.whl
.
File metadata
- Download URL: loaf-0.2.9-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 530c75569019188cd7b55989f1aeba0b8f6715905db980804c4dab440db6a21e |
|
MD5 | 1c9d0850ab95ee5be7b4880168534389 |
|
BLAKE2b-256 | 0316ec1e158fbb4c0d40bf2f918a58788945edd8f57b8e6bc79b6fd7edf25370 |