PyQuickSQL
For a more thorough explanation see example.md
To install: pip install qsql
How to use the query loader:
import quicksql as qq
queries = qq.LoadSQL('path/to/queries.sql')
Printing the queries should give you something like this:
LoadSQL('path/to/queries.sql')
Query Name: examplequery_1, Params: order_avg, num_orders
Query Name: examplequery_2, Params: sdate, edate, product_id
These are callable objects that return the string given the non-optional **params.
They are equivalent to an f-string + a lambda but loaded from an sql file and stored in the LoadSQL object.
print(str(queries)) will give you the raw SQL string.
How to use them:
print(queries.examplequery_2(
product_id=10,
sdate='1-10-2022',
edate=qq.NoStr("DATE'4-11-2023'"),
something_not_a_param='test'))
Unused variables: something_not_a_param in query examplequery_2
Above will be printed as a warning with invalid inclusions, no non-verbose option yet.
SELECT
c.CustomerName,
o.OrderDate,
o.Status,
(SELECT SUM(od.Quantity * od.UnitPrice) FROM OrderDetails od WHERE od.OrderID = o.OrderID) AS TotalValue
FROM
Customers c
INNER JOIN Orders o ON c.CustomerID = o.CustomerID
WHERE
o.OrderDate BETWEEN '1-10-2022' AND DATE'4-11-2023'
AND EXISTS (SELECT 1 FROM OrderDetails od WHERE od.OrderID = o.OrderID AND od.ProductID = 10)
ORDER BY
TotalValue DESC;
How to use the file cache:
This is very similar to functool's cache, with the main difference being that @qq.file_cache caches the asset to memory
and to your system's default temporary directory. If the memory cache ever fails (eg a restarted kernel) it will load the asset from it's pickled file.
from random import randint
import quicksql as qq
@qq.file_cache()
def test_mem(size:int):
return [randint(0,10) for _ in range(size)]
print(test_mem(8))
[10, 3, 4, 9, 2, 2, 4, 2]
print(test_mem(8))
[10, 3, 4, 9, 2, 2, 4, 2]
To clear the cache: qq.clear_cache()
For more examples and how to configure see example.ipynb
Metadata
Release files for qsql 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qsql-1.0.3.tar.gz | 12.5 kB | Without provenance | Details for qsql-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qsql-1.0.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for qsql-1.0.3-py2.py3-none-any.whl |
Total release size: 19.3 kB
Release files / qsql-1.0.3.tar.gz
| Download URL | qsql-1.0.3.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce6f2345796b96c03a68e3ac4f643b544ac0ed67c578a50be390b81a31b5c88d
|
|
BLAKE2b-256 checksum How to use checksums |
c2345d23b04dda9aa671d8a4e69343b19d6c19dbc09a8f8fa50a5d36e0859bf5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.3
|
Release files / qsql-1.0.3-py2.py3-none-any.whl
| Download URL | qsql-1.0.3-py2.py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2d6635bb8d290a6e75268f02980d86bddb3ca0851e726357c086d8f9bf9a6b85
|
|
BLAKE2b-256 checksum How to use checksums |
5cc7cb08a122326b60e70a2d3d38277e5fc57f8160408a810194c32a8021ac3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.3
|
Security for qsql 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.