Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/poshodev/loaf
π Effortless SQL server and proceduresβplus other utilitiesβfor people who really hate cursors!
https://github.com/poshodev/loaf
bread database db loaf mariadb mysql python sql
Last synced: 4 months ago
JSON representation
π Effortless SQL server and proceduresβplus other utilitiesβfor people who really hate cursors!
- Host: GitHub
- URL: https://github.com/poshodev/loaf
- Owner: PoshoDev
- Created: 2021-10-19T00:09:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-09T04:39:41.000Z (about 1 year ago)
- Last Synced: 2024-10-11T03:05:28.190Z (4 months ago)
- Topics: bread, database, db, loaf, mariadb, mysql, python, sql
- Language: Python
- Homepage: https://pypi.org/project/Loaf/
- Size: 114 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π 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
```python
from loaf import Loaf
```### Setting Up Credentials
```python
# 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
```python
# 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
```python
# Display info using built-in tables!
loaf.print(pepperoni_id)
loaf.print(client_name)
loaf.print(toppings)
``````powershell
ββββββ
β id β
β‘βββββ©
β 1 β
ββββββ
βββββββββββββ
β name β
β‘ββββββββββββ©
β 'Alfonso' β
βββββββββββββ
ββββββ³ββββββββββββββ³ββββββββ
β id β name β price β
β‘βββββββββββββββββββββββββββ©
β 1 β 'Pepperoni' β 1.49 β
β 2 β 'Mushrooms' β 1.99 β
β 3 β 'Onions' β 0.99 β
ββββββ΄ββββββββββββββ΄ββββββββ
```### Data Manipulation
```python
# Manipulate your data with dictionaries, as God intended.
for topping in toppings:
print(topping['name'])
```````powershell
Pepperoni
Mushrooms
Onions
````### Utilities
```python
# 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)
```![](https://github.com/PoshoDev/Loaf/blob/main/loaf.png?raw=true)
β οΈ 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
```