Skip to main content

Convenience wrapper for DB API and csv.DictReader rows, and similar.

Project description

brunns-row

Convenience wrapper for DB API and csv.DictReader rows, and similar, inspired by Greg Stein's lovely dtuple module.

made-with-python Build Status PyPi Version Python Versions Licence GitHub all releases GitHub forks GitHub stars GitHub watchers GitHub contributors GitHub issues GitHub issues-closed GitHub pull-requests GitHub pull-requests closed Codacy Badge Codacy Coverage Documentation Status Lines of Code

Installation

Install with pip:

pip install brunns-row

Or with uv:

uv add brunns-row

Usage

The basic approach is to create a wrapper object from some kind of description - typically a DBAPI cursor's description, or a csv.DictReader's fieldnames attribute - then to use the wrapper's wrap(row) method to wrap each row. wrap(row) returns an object from which you can access the row's fields as attributes. A couple of simple examples:

DB API

cursor = conn.cursor()
cursor.execute("SELECT kind, rating FROM sausages ORDER BY rating DESC;")
wrapper = RowWrapper(cursor.description)
rows = [wrapper.wrap(row) for row in cursor.fetchall()]
for row in rows:
    print(row.kind, row.rating)

csv.DictReader

reader = csv.DictReader(csv_file)
wrapper = RowWrapper(reader.fieldnames)
rows = [wrapper.wrap(row) for row in reader]
for row in rows:
    print(row.kind, row.rating)

Attributes names are simply the column names where possible, converted to valid identifiers where necessary by replacing invalid characters with "_"s, prefixing any leading numerics with "a_", and de-duplicating where necessary by adding numeric suffixes.

Development

This project uses uv for dependency management and development.

Setup

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone and setup
git clone https://github.com/brunns/brunns-row.git
cd brunns-row
uv sync --all-extras

Common Commands

# Run tests
uv run pytest

# Run tests with coverage
uv run pytest --cov=src/brunns --cov-report=term-missing

# Format code
uv run ruff format .

# Lint
uv run ruff check .

# Type check
uv run mypy src/

# Build docs
uv run sphinx-build docs build_docs --color -W -bhtml

# Run all pre-commit checks
make precommit

For more options:

make help

Releasing

Releases are automated via GitHub Actions. To release version n.n.n:

  1. Update version in pyproject.toml (using uv version --bump major|minor|patch) and docs/conf.py.
  2. Run make precommit to ensure all checks pass
  3. Commit and tag:
    version=`uv version --short`
    git pull -r
    git commit -am "Release v$version"
    git tag "v$version"
    git push origin master --tags
    

The GitHub Actions workflow will automatically:

  • Run tests and coverage checks
  • Build distribution packages
  • Publish to PyPI (using OIDC trusted publishing)
  • Create a GitHub release with auto-generated notes

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

brunns_row-2.2.0.tar.gz (70.9 kB view details)

Uploaded Source

Built Distribution

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

brunns_row-2.2.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file brunns_row-2.2.0.tar.gz.

File metadata

  • Download URL: brunns_row-2.2.0.tar.gz
  • Upload date:
  • Size: 70.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for brunns_row-2.2.0.tar.gz
Algorithm Hash digest
SHA256 69379d1f0992c2611e90a713678cb252ebdcd3ba021c43aa479289586deeed2b
MD5 f2e2bbc68bcfbe16e28139d421312b35
BLAKE2b-256 5aab071c27271e59b80a93ab5ff6387051a8ecdc72f821d22369f31240e7c6a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for brunns_row-2.2.0.tar.gz:

Publisher: release.yml on brunns/brunns-row

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file brunns_row-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: brunns_row-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for brunns_row-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ed1a695578bfecc5385db291a618f0c26bcdf2c09533a9076f983466c65229cb
MD5 eb519b78847b1b2cb7196dba6850de96
BLAKE2b-256 5523104814874067726d4b1c076dbcbcbd255ff45ffdf6ac5676663d647eb2dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for brunns_row-2.2.0-py3-none-any.whl:

Publisher: release.yml on brunns/brunns-row

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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