Lilliepy-query
this is a sub module for the lilliepy framework to be able to query and cache queries effectivly
dependecies
- request
- time
- threading
- reactpy
- asyncio
how to use
Import:
step 1:
pip install lilliepy-query
step 2:
from lilliepy-query import Fetcher, use_query
Syntax for Fetcher:
this is for the people who want to use a class, rather than a function hook
you will be using these 4 lines of code the most:
from lilliepy import Fetcher
req = query.Fetcher("https://jsonplaceholder.typicode.com", refetch_interval=2) # initilizes the Fetcher class, you will now be able to start fetching and caching data, params are listed in the class comment docs
req.fetch("/todos/3") # fetches the data, since the base url is "https://jsonplaceholder.typicode.com", it will fetch from "https://jsonplaceholder.typicode.com/todos/3"
req.refetch("/todos/3") # refetches every interval stated by the Fetcher init, in this case, 2
data, err, load = req.get_state() # 3 vars are declared here: data, for the data from the fetch; error, for containing any error from preforming the fetch; and load, to indicate if the fetch is still loading or not
Syntax for use_query:
this is for the people who want to have a function hook
# MainPage.x.py
# the title of the page that was specified above is the file arrangement so that lilliepy-dir-router can route it correctly
from reactpy import component, html
from lilliepy-query import use_query
import httpx # if you want to use this
async def fetch_example_data(): # fetching function (pro tip: you can use the Fetcher for this part!!!)
async with httpx.AsyncClient() as client:
response = await client.get("https://api.example.com/data")
response.raise_for_status()
return response.json()
@component
def MainPage():
query = use_query(
query_key="example-data", # query key
fetch_function=fetch_example_data, # query function
enabled=True, #should it execute on mount, in this case, yes
refetch_interval=30 # Refetch every 30 seconds
)
if query["is_loading"]: # if query is loading
return html.div("Loading...")
if query["error"]: #if query had an error
return html.div(f"Error: {query['error']}")
if query["data"]: #when query gets data
return html.div(f"Data: {query['data']}")
return html.div("No data available.") #nothing came out (shouldnt happen)
Metadata
Release files for lilliepy-query 0.1
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 |
|---|---|---|---|---|
| lilliepy_query-0.1.tar.gz | 4.5 kB | Without provenance | Details for lilliepy_query-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lilliepy_query-0.1-py3-none-any.whl | Python 3 | none | any | Details for lilliepy_query-0.1-py3-none-any.whl |
Total release size: 9.3 kB
Release files / lilliepy_query-0.1.tar.gz
| Download URL | lilliepy_query-0.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e803f9fc348d1106b2ca783b8d6315da35952eb0f015dbcae8ba663c0c244cda
|
|
BLAKE2b-256 checksum How to use checksums |
8173c64281a48d498c8bf307b86eac7f8a772534a8cb926abc22772d6cbeccfd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.1
|
Release files / lilliepy_query-0.1-py3-none-any.whl
| Download URL | lilliepy_query-0.1-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
59f94debd830c4f7e1a6ce2a85622f16feb9e59f7e1cc893203e9de44ef9ae38
|
|
BLAKE2b-256 checksum How to use checksums |
b777e83a1b7c5ef0e3637ac1ec75af182898933091d87ee535d5209ef663b7c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.1
|
Security for lilliepy-query 0.1
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.