Skip to main content

Lightweight library to handle data and reproduce workflows

Project description

Penwings

Penwings is a lightweight Python library designed to simplify SQL data workflows by automatically importing data from SQL and caching it as Parquet files. This ensures faster subsequent access and reproducible pipelines, while reducing database get.


Table of Contents

  1. Features
  2. Installation
  3. Getting Started
  4. Usage
  5. Versioning
  6. Contributing
  7. License

Features

  • get data from SQL queries or SQL files
  • Automatically save query results as Parquet files
  • Reuse Parquet files to avoid redundant queries
  • Simple, stable API for reproducible workflows
  • Optimized for performance and ease of integration

Installation

Install via pip:

pip install penwings

Make sure you have Python 3.11+ installed.


Getting Started

Importing the Library

from penwings import SQLParquetCache

Initialize the Cache

You can initialize the cache by providing either a SQL directory or a query string, along with a Parquet directory:

from sqlalchemy import create_engine

SQL connection

engine = create_engine("postgresql://user:password@localhost/dbname")

# Initialize the cache
loader = SQLParquetCache(
    sql_dir="sql_files",        # Optional if using query string
    parquet_dir="parquet_cache",
    conn=engine
)

Usage

1. Using SQL Files

If you have SQL files stored in a directory:

# Run a SQL file and cache the result
df = loader.get("monthly_sales.sql")
  • penwings will automatically check if a Parquet version exists.
  • If it exists, the cached Parquet is loaded.
  • If not, the SQL query runs and the result is saved as a Parquet file.

2. Using SQL Query Strings

You can also pass queries directly:

query = "SELECT * FROM sales WHERE month='2026-02'"
df = loader.get(sql=query, parquet_name="sales_feb2026")
  • parquet_name determines the Parquet file name.
  • Works similarly to SQL file mode for caching.

3. Automatic Parquet Management

  • All results are cached in the specified parquet_dir.
  • This reduces repeated database queries and ensures reproducibility.
  • Cached files can be reloaded for faster access.

Versioning

Penwings follows semantic versioning:

  • MAJOR: Breaking changes to API
  • MINOR: New features, backward-compatible
  • PATCH: Bug fixes

Contributing

We welcome contributions!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -m 'Add new feature')
  4. Push to branch (git push origin feature/my-feature)
  5. Open a pull request

Please ensure your code follows PEP8 standards.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Example Workflow

from sqlalchemy import create_engine
from penwings import SQLParquetCache

engine = create_engine("sqlite:///example.db")

loader = SQLParquetCache(
    sql_dir="sql_queries",
    parquet_dir="parquet_cache",
    conn=engine
)

# get data
df_jan = loader.get("sales_january.sql")
df_feb = loader.get(sql="SELECT * FROM sales WHERE month='2026-02'", parquet_name="sales_feb")
  • SQL files are automatically cached as Parquet
  • Subsequent loads are fast and do not hit the database

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

penwings-0.2.4.tar.gz (75.4 kB view details)

Uploaded Source

Built Distribution

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

penwings-0.2.4-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file penwings-0.2.4.tar.gz.

File metadata

  • Download URL: penwings-0.2.4.tar.gz
  • Upload date:
  • Size: 75.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for penwings-0.2.4.tar.gz
Algorithm Hash digest
SHA256 dfe3171bb034b66ef2adb366d1f9aa1d166d0940c999dfef637fd22fdc0cd03b
MD5 37c1fc37c8f269ff35fac43c63446eed
BLAKE2b-256 1ef7bc3baad17434f0cea2d8a567aa3e8fbbb1d0a275934a9f1d7f2ff9223a77

See more details on using hashes here.

File details

Details for the file penwings-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: penwings-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for penwings-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 07bcbe03ac53a357e9706e8b9d46f91972c096d08979a8d26ce81af9e721a05f
MD5 e0988eae3424124409552b40746bfd0f
BLAKE2b-256 c8a546d28acfb7531c324d137a25451b2139e2b0ebc4c2f08661ae3cd697f777

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