Skip to main content

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

Metadata

Release files for penwings 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for penwings 0.2.4
File Size Uploaded Provenance Actions
penwings-0.2.4.tar.gz 75.4 kB Without provenance Details for penwings-0.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for penwings 0.2.4
File Interpreter ABI Platform Actions
penwings-0.2.4-py3-none-any.whl Python 3 none any Details for penwings-0.2.4-py3-none-any.whl

Total release size: 86.6 kB

Release files / penwings-0.2.4.tar.gz

Download URL penwings-0.2.4.tar.gz
Size 75.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dfe3171bb034b66ef2adb366d1f9aa1d166d0940c999dfef637fd22fdc0cd03b
BLAKE2b-256 checksum
How to use checksums
1ef7bc3baad17434f0cea2d8a567aa3e8fbbb1d0a275934a9f1d7f2ff9223a77
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / penwings-0.2.4-py3-none-any.whl

Download URL penwings-0.2.4-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07bcbe03ac53a357e9706e8b9d46f91972c096d08979a8d26ce81af9e721a05f
BLAKE2b-256 checksum
How to use checksums
c8a546d28acfb7531c324d137a25451b2139e2b0ebc4c2f08661ae3cd697f777
Upload date
Uploaded using Trusted Publishing?
What is 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}

Security for penwings 0.2.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page