Skip to main content

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


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.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

loaf-0.2.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file loaf-0.2.2.tar.gz.

File metadata

  • Download URL: loaf-0.2.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.6

File hashes

Hashes for loaf-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e80e68be91bc07852c3e7eb2ea68b2314bb1fb6c804145e1d3b2cf26e79c7cc3
MD5 30c7a8ec54bd3cb6f74b87f434bc0525
BLAKE2b-256 ba68222399c4a5fa2006a8c1bcaa79b2632b9ce910b6504d882a63067304f5f9

See more details on using hashes here.

File details

Details for the file loaf-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: loaf-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.6

File hashes

Hashes for loaf-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 29c42040a3e093ee20efa161d2588aa66f76c55202f7964fb518e1f2872485b9
MD5 6158b3036ea390c6f3b12f18ccd44ad8
BLAKE2b-256 e3a6ed314121cc7ba4582ce0acbc375162881b45ba53baf76dec262e318804d6

See more details on using hashes here.

Supported by

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