Skip to main content

rec-avro:

Avro support for JSON and other nested data structures.

Rec-avro provides a generic Avro schema and converter functions that allow for storing nested python data structures in avro.

Tested in Python 3 only.

Installation:

$ pip3 install rec-avro

Usage:

With fastavro:

from fastavro import writer, reader, schema
from rec_avro import to_rec_avro_destructive, from_rec_avro_destructive, rec_avro_schema

def json_objects():
    return [{'a': 'a'}, {'b':'b'}]

# For efficiency, to_rec_avro_destructive() destroys rec, and reuses it's
# data structures to construct avro_objects 
avro_objects = (to_rec_avro_destructive(rec) for rec in json_objects())

# store records in avro
with open('json_in_avro.avro', 'wb') as f_out:
    writer(f_out, schema.parse_schema(rec_avro_schema()), avro_objects)

#load records from avro
with open('json_in_avro.avro', 'rb') as f_in:
    # For efficiency, from_rec_avro_destructive(rec) destroys rec, and 
    # reuses it's data structures to construct it's output
    loaded_json = [from_rec_avro_destructive(rec) for rec in reader(f_in)]

assert loaded_json == json_objects()

Development:

# Running all tests:
$ python setup.py pytest

# Running tests manually
$ pip3 install fastavro pytest
$ python setup.py develop
$ pytest tests/test_rec_avro.py

Metadata

Release files for rec-avro 0.0.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 rec-avro 0.0.4
File Size Uploaded
rec-avro-0.0.4.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rec-avro 0.0.4
File Interpreter ABI Platform
rec_avro-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 7.1 kB

Release files / rec-avro-0.0.4.tar.gz

Download URL rec-avro-0.0.4.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8e7217d56e46bb0fe9ef5a156e04400b4a3bbdf7612920c3f8f2670d840bd249
BLAKE2b-256 checksum
How to use checksums
e4c16f85a5b6fce4f04bd5e1546e02ccb99c3699cc7d96e2826be044a5e395bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Release files / rec_avro-0.0.4-py3-none-any.whl

Download URL rec_avro-0.0.4-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
543951512dabeaa83f354d34c34815e7f0decb961fb8c42a2961b6aa11eb2e12
BLAKE2b-256 checksum
How to use checksums
14feb9bb0a22fbd3fe4f4b1502a2a1f003e1f7f3511d8142ba9501dc0b46e939
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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