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.
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 a new version:
- Update the version number in
pyproject.toml - Run the pre-commit checks:
make precommit - Commit, tag, and push:
git commit -am "chore: bump version to X.Y.Z" git push git tag vX.Y.Z git push --tags
The release workflow will automatically:
- Run tests
- Build the package
- Publish to PyPI
- Create a GitHub Release with release 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brunns_row-2.1.1.tar.gz.
File metadata
- Download URL: brunns_row-2.1.1.tar.gz
- Upload date:
- Size: 75.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1323680c0e24624fe87669e1682bda6995ca2e7e882983cd1c135074da284539
|
|
| MD5 |
68219c320ffcf9f0cb6901770b43b496
|
|
| BLAKE2b-256 |
cc08d5d841b5633cb114bb0cc67a87661e6ecde519a5af0de9e88c0972b5d33f
|
Provenance
The following attestation bundles were made for brunns_row-2.1.1.tar.gz:
Publisher:
release.yml on brunns/brunns-row
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brunns_row-2.1.1.tar.gz -
Subject digest:
1323680c0e24624fe87669e1682bda6995ca2e7e882983cd1c135074da284539 - Sigstore transparency entry: 937067542
- Sigstore integration time:
-
Permalink:
brunns/brunns-row@7781cace0ec9968311bb48110d70149bea2a032b -
Branch / Tag:
refs/tags/v2.1.1 - Owner: https://github.com/brunns
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7781cace0ec9968311bb48110d70149bea2a032b -
Trigger Event:
push
-
Statement type:
File details
Details for the file brunns_row-2.1.1-py3-none-any.whl.
File metadata
- Download URL: brunns_row-2.1.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73f7660f279488c8927d2c9c5f6a6dfb990213508f2918f6ac3e0be4e43327a5
|
|
| MD5 |
f5dc5081ac04186e589765f030156e67
|
|
| BLAKE2b-256 |
762135c806398c0bb599d32be3a4604a73408e354d75c5c1186d746879382e16
|
Provenance
The following attestation bundles were made for brunns_row-2.1.1-py3-none-any.whl:
Publisher:
release.yml on brunns/brunns-row
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brunns_row-2.1.1-py3-none-any.whl -
Subject digest:
73f7660f279488c8927d2c9c5f6a6dfb990213508f2918f6ac3e0be4e43327a5 - Sigstore transparency entry: 937067544
- Sigstore integration time:
-
Permalink:
brunns/brunns-row@7781cace0ec9968311bb48110d70149bea2a032b -
Branch / Tag:
refs/tags/v2.1.1 - Owner: https://github.com/brunns
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7781cace0ec9968311bb48110d70149bea2a032b -
Trigger Event:
push
-
Statement type: