A simple utility tool that scan SQL files with queries separated by comments into python dicts.
Project description
SQLoad
A simple utility tool that scan SQL files with queries separated by comments into python dicts.
Usage
Given a file called queries.sql
with the following content:
-- find-all-by-name
SELECT * FROM users WHERE name = :name
-- find-one-by-id
SELECT * FROM users WHERE id = 10 LIMIT 1
-- find-users-join-products
SELECT * FROM users u
INNER JOIN products p ON u.id = p.user_id
WHERE u.id = 1
LIMIT 1
You can load those queries into dicts as follow:
from sqload import load
q = load('queries.sql')
assert q['find-all-by-name'] == "SELECT * FROM users WHERE name = :name"
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
sqload-0.1.0.tar.gz
(1.7 kB
view details)
Built Distribution
File details
Details for the file sqload-0.1.0.tar.gz
.
File metadata
- Download URL: sqload-0.1.0.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2faf7afe4fd4e1ca21a85c2409adbd42e8f4174a6325c548f6f398e929a635d |
|
MD5 | 54d84f2ea1151c132447aa35072e8e0b |
|
BLAKE2b-256 | 45684f19359a2f21a532d8d8db4e7dd49721b87ce806bb9ecee5da004605515a |
File details
Details for the file sqload-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: sqload-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5863a4b5fc3f681b36ac0d293a702ac1157b1e53ebfd2983d9e0a60de56ef53 |
|
MD5 | db4e26dc504d5e417b69a949ceac27db |
|
BLAKE2b-256 | d64699c3cc3b2e45a1f0fa523a7b01babfa02c8683534d3dd734c7f89f1bcf56 |