ETL framework for Colosscious Pharmquer
Project description
lichens
ETL framework for Colosscious Pharmquer.
It contains a Web UI and a backend. See Colosscious Official Website for more.
Installation
pip install lichens
Example
Setup
# Command
python -m lichens --help
# Output:
# Usage: python -m lichens [OPTIONS] COMMAND [ARGS]...
#
# Options:
# --help Show this message and exit.
#
# Commands:
# add-etl Add an ETL program setting from a JSON
# get-template Generate an ETL program setting to a JSON
# migrate Make and migrate the system tables.
# Initialize the database if needed.
python -m lichens migrate \
-c driver://user:pass@localhost:port/dbname
# Create an ETL setting template
python -m lichens get-template \
# Create it in the database
python -m lichens add-etl \
--connection-string driver://user:pass@localhost:port/dbname \
--json-config etl-setting.json
Write an ETL
See full example
# Create an ETL Manager
from lichens import EtlManager
em = EtlManager(constr=CONNECTION_STRING, name=ETL_NAME)
# Use Pandera to validate data
from lichens import DataFrameSchema, check_io
schema = DataFrameSchema(...)
validated_df = schema(df)
## Load df to datebase
em.load_df(
df=df,
tablename="sample_table",
schema="public",
if_exists="raise_error",
chunksize=500,
unique_key=["column1", "column2"],
)
# Update log and archive file
em.update_status(
filename=f,
status=_status,
last_log=_last_log)
em.move(
src=os.path.join(em.src_folder, f),
status=_status)
# Use state highlighted logger
from lichens.logging import logger as log
# Run as scheduled
## Define a function to be executed
def your_function():
# Your function logic here
pass
# Run the function every minute for a total of 5 times
em.run_as_schtask(your_function, '*/1 * * * *', times_=5)
## Decorate the function with the scheduled decorator
@em.scheduled(crontab='*/1 * * * *', times_=5)
def your_scheduled_function():
# Your function logic here
pass
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
lichens-0.1.0.tar.gz
(24.7 kB
view details)
Built Distribution
lichens-0.1.0-py3-none-any.whl
(17.9 kB
view details)
File details
Details for the file lichens-0.1.0.tar.gz
.
File metadata
- Download URL: lichens-0.1.0.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.13 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14ff5731fb6663adef4945214aa2c243482d0f4a1a872da5750c1f9604550924 |
|
MD5 | 364c9a7968f72ff4eb2e8fad137c15ae |
|
BLAKE2b-256 | d6b317723daca24b72f87db6df6024562dd6beaf8b8b6f4860a591c852ec34ce |
File details
Details for the file lichens-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: lichens-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.13 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88d4218106e25d44b045968d4845a82cd0c3863ca27587d67d74d0e436b41945 |
|
MD5 | 0666b7d2c584a19ee0334c7edb7ee941 |
|
BLAKE2b-256 | c1a603119be2655bf1706319460bdaaf54759509368fd108f3cfcc7bb0d7d1c1 |