A library for building inline SQL queries safely using python callables.
Project description
lonny_common_sql
A library for building inline SQL queries safely using python callables
.
Installation:
pip install lonny_common_sql
Usage:
Usage is very straightforward. Please see example below:
from lonny_common_sql import build
table = "TABLE"
value = "VALUE"
sql, params = build(lambda w: f"""
SELECT * FROM {table}
WHERE value = {w(value)}
""")
We simply pass build
a callable that takes a wrapper
argument. This wrapper is itself a callable
that returns the substituted parameter name whilst simultaneously adds the value to the parameter dictionary to be returned along with the finalized SQL.
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
lonny_common_sql-0.1.1.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for lonny_common_sql-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae5d5188c273eb12fe571c956b210250a45a09cb8434d92e2c863253b1701b06 |
|
MD5 | 0cded5ecd5af21127daa14cac9a1c744 |
|
BLAKE2b-256 | ed84380327c95ba9427b526c1efc206b4912ad28b0cce44b7dbdcc7e4de68922 |