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.2.tar.gz (74.7 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.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: penwings-0.2.2.tar.gz
  • Upload date:
  • Size: 74.7 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.2.tar.gz
Algorithm Hash digest
SHA256 854a04445c2c135d64464932f8c0cea9270dff9d6fe33c04cfde0615a39bb03d
MD5 4403dafd8605a80fba3c14afeefc4006
BLAKE2b-256 7a1f25400e684a87c255df2acd53f0660b5fcb5277c3fb52a68f8d49c5d42492

See more details on using hashes here.

File details

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

File metadata

  • Download URL: penwings-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 10.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b7345f347d400de5ee0b2bdbb191be94c39a5a4c671e926f4bac891672ed1aeb
MD5 b74a22de2b36ef6b32d40cdc0377673c
BLAKE2b-256 c459ea898de587a4c015d1cd02d1aa34e143f74c55641cc446c7e9fa3fd56a91

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