Skip to main content

dpetl — Data package ETL

Release Coverage

The dpetl is a command-line interface (CLI) tool designed to run the three ETL phases (Extract, Transform, Load)1

It is designed to work alongside the Data Package standard specification.

Installation

It requires Python 3.10 or more. Install:

# using pip
pip install dpetl

# using poetry
poetry add dpetl

Usage

Active your virtual environment!

Use the --help flag to inspect the CLI documentation:

dpetl --help

Currently, only the extract command is available:

# Run extract using the default datapackage.yaml descriptor
dpetl extract

# Specify a descriptor explicitly
dpetl -d path/to/datapackage.yaml extract
# or
dpetl --descriptor path/to/datapackage.yaml extract

The --descriptor/-d option is global and should be placed before the any ETL command.

How It Works

The CLI loads Data Package descriptor(s) (via the frictionless-py Python package) and iterates over its resources.

A .toml file could also be provided as a descriptor (using the -d flag) to run the command(s) recursively. Please create a .toml file following the below pattern:

title = 'dados_orcamentarios'

[datapackages] # required

[datapackages.dados_siafi]
path = 'datapackages/dados_siafi/datapackage.yaml' # descriptor required via path property

[datapackages.dados_sisor]
path = 'datapackages/dados_sisor/datapackage.yaml' # descriptor required via path property

For each resource found, dpetl extract command reads its dpetl_extract custom property: The key mode determines which extractor will run. Currently, available modes are:

  • api.
  • email.

Example Data Package Configuration

# datapackage.yaml
resources:
  - name: invoices
    path: data/invoices.csv
    sources:
      - method: get
        path: https://api.example.com/invoices
    dpetl_extract:
      mode: api

  - name: payroll_from_email
    path: data/payroll.xlsx
    dpetl_extract:
      mode: email
      mailbox: INBOX  # optional (Defaults to INBOX)
      criteria:
        subject: "Payroll Report" # optional (Defaults to resource name. See also the flag --add-package-name)

Extractors

Email Extractor

  • Connects to an IMAP server using environment variables:

    • EMAIL_USER.
    • EMAIL_PWD.
    • EMAIL_IMAP.
    • HTTP_PROXY2.
  • Reads configuration from:
dpetl_extract:
  mode: email
  mailbox: INBOX        # optional (Defaults to INBOX)
  criteria:             # optional
    subject: "Report"   # optional (Defaults to resource name. See also the flag --add-package-name)
    from_: "finance@example.com" # optional
    date_gte: 2024-01-01 #optional (See also the flag --today-email)

Behavior:

  • If dpetl_extract.mailbox is not provided, INBOX is used.
  • If dpetl_extract.criteria.subject is not provided, it defaults to the resource name.
  • If the flag --add-package-name is provided the e-mail subject pattern will be {package_name}_{resource_name} instead of just resource name.
  • If the flag --today-email is provided the date when the command runs will be used in the to search criteria.
  • The extractor searches for the most recent matching e-mail.
  • All e-mail attachments are saved to resource.path.

API Extractor

  • Reads resource.sources.
  • Searches for a source containing a method.
  • Downloads the file.
  • Saves it to resource.path.

Design Philosophy

The dpetl package follows a convention over configuration philosophy, treating the Data Package descriptor as the single source of truth for ETL process.

Each resource declares how it should be processed through structured metadata, enabling reproducible, declarative, and version-controlled data workflows.

The goal is to keep the CLI simple while allowing flexible strategies driven entirely by configuration rather than imperative scripting.

  1. Although currently only the Extract phase is implemented.

  2. Just in case you're running the command behind a corporate network that demands proxy configuration. The HTTP_PROXY, HTTPS_PROXY, http_proxy and https_proxy environment variables are equally acceptable. See this Issue's comment to understand why maybe you'll have to add authentication (http://<user>:<pwd>@<host>:<port>) on PROXY address.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dpetl-0.9.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dpetl-0.9.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file dpetl-0.9.0.tar.gz.

File metadata

  • Download URL: dpetl-0.9.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.10.12 Linux/6.17.9-76061709-generic

File hashes

Hashes for dpetl-0.9.0.tar.gz
Algorithm Hash digest
SHA256 45b4278a29047a466138aa28150ef606471ad3106f53f46944b26b6b60c3a3f4
MD5 56769dc1a4f8f22856f2916ec499ee37
BLAKE2b-256 f6acd6824af66b5dcfc888c38b732b0ff8306befd41a34de659ffd070394bf82

See more details on using hashes here.

File details

Details for the file dpetl-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: dpetl-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.10.12 Linux/6.17.9-76061709-generic

File hashes

Hashes for dpetl-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebe491cae99b7cff3f6078e0b9edee9f73e2b338b3105403c981486ceab65077
MD5 187a57a561c6f641f2a109de1c54ae92
BLAKE2b-256 d090f3fb648fbe71f7be0976c7a6ba804e5bf81a408780f8fd77850bd544ef12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page