Skip to main content

Arrow, pydantic style

Project description

Welcome to arrowdantic

Arrowdantic is a small Python library backed by a mature Rust implementation of Apache Arrow that can interoperate with

For simple (but data-heavy) data engineering tasks, this package essentially replaces pyarrow: it supports reading from and writing to Parquet, Arrow at the same or higher performance and higher safety (e.g. no segfaults).

Furthermore, it supports reading from and writing to ODBC compliant databases at the same or higher performance than turbodbc.

This package is particularly suitable for environments such as AWS Lambda - it takes 8M of disk space, compared to 82M taken by pyarrow.

Features

  • declare and access Arrow-backed arrays (integers, floats, boolean, string, binary)
  • read from and write to Apache Arrow IPC file
  • read from and write to Apache Parquet
  • read from and write to ODBC-compliant databases (e.g. postgres, mongoDB)

Examples

Use parquet

import io
import arrowdantic as ad

original_arrays = [ad.UInt32Array([1, None])]

schema = ad.Schema(
    [ad.Field(f"c{i}", array.type, True) for i, array in enumerate(original_arrays)]
)

data = io.BytesIO()
with ad.ParquetFileWriter(data, schema) as writer:
    writer.write(ad.Chunk(original_arrays))
data.seek(0)

reader = ad.ParquetFileReader(data)
chunk = next(reader)
assert chunk.arrays() == original_arrays

Use Arrow files

import arrowdantic as ad

original_arrays = [ad.UInt32Array([1, None])]

schema = ad.Schema(
    [ad.Field(f"c{i}", array.type, True) for i, array in enumerate(original_arrays)]
)

import io

data = io.BytesIO()
with ad.ArrowFileWriter(data, schema) as writer:
    writer.write(ad.Chunk(original_arrays))
data.seek(0)

reader = ad.ArrowFileReader(data)
chunk = next(reader)
assert chunk.arrays() == original_arrays

Use ODBC

import arrowdantic as ad


arrays = [ad.Int32Array([1, None]), ad.StringArray(["aa", None])]

with ad.ODBCConnector(r"Driver={SQLite3};Database=sqlite-test.db") as con:
    # create an empty table with a schema
    con.execute("DROP TABLE IF EXISTS example;")
    con.execute("CREATE TABLE example (c1 INT, c2 TEXT);")

    # insert the arrays
    con.write("INSERT INTO example (c1, c2) VALUES (?, ?)", ad.Chunk(arrays))

    # read the arrays
    with con.execute("SELECT c1, c2 FROM example", 1024) as chunks:
        assert chunks.fields() == [
            ad.Field("c1", ad.DataType.int32(), True),
            ad.Field("c2", ad.DataType.string(), True),
        ]
        chunk = next(chunks)
assert chunk.arrays() == arrays

Use timezones

This package fully supports datetime and conversions between them and arrow:

import arrowdantic as ad


dt = datetime.datetime(
    year=2021,
    month=1,
    day=1,
    hour=1,
    minute=1,
    second=1,
    microsecond=1,
    tzinfo=datetime.timezone.utc,
)
a = ad.TimestampArray([dt, None])
assert (
    str(a)
    == 'Timestamp(Microsecond, Some("+00:00"))[2021-01-01 01:01:01.000001 +00:00, None]'
)
assert list(a) == [dt, None]
assert a.type == ad.DataType.timestamp(datetime.timezone.utc)

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

arrowdantic-0.2.1.tar.gz (15.8 kB view details)

Uploaded Source

Built Distributions

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

arrowdantic-0.2.1-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.9 MB view details)

Uploaded PyPymanylinux: glibc 2.12+ x86-64

arrowdantic-0.2.1-cp310-none-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.10Windows x86-64

arrowdantic-0.2.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.12+ x86-64

arrowdantic-0.2.1-cp310-cp310-macosx_10_7_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10macOS 10.7+ x86-64

arrowdantic-0.2.1-cp39-none-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.9Windows x86-64

arrowdantic-0.2.1-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

arrowdantic-0.2.1-cp39-cp39-macosx_10_7_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9macOS 10.7+ x86-64

arrowdantic-0.2.1-cp38-none-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.8Windows x86-64

arrowdantic-0.2.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

arrowdantic-0.2.1-cp38-cp38-macosx_10_7_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.8macOS 10.7+ x86-64

arrowdantic-0.2.1-cp37-none-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.7Windows x86-64

arrowdantic-0.2.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

arrowdantic-0.2.1-cp37-cp37m-macosx_10_7_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.7mmacOS 10.7+ x86-64

File details

Details for the file arrowdantic-0.2.1.tar.gz.

File metadata

  • Download URL: arrowdantic-0.2.1.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for arrowdantic-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ab01c169bcaf456473d8b1595672edfcc13f1f9b7881e21570287b982f4f2003
MD5 acbd17ec25f48e67940093620045ee6f
BLAKE2b-256 061a19bfe70ef5bb19a99097e71bc3697f59ab5dd5f7f2496004574ffd3190ad

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for arrowdantic-0.2.1-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9efed62333c93e2894bea8e7f3aee82b801a1fdaf617d0652527992f6c96f74c
MD5 9a949bd5e579ca40da1690acae10e258
BLAKE2b-256 16f739d46813611112bf99b03dd5dc8f6a6409c1f1be8da34a008e7edbec9df8

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp310-none-win_amd64.whl.

File metadata

  • Download URL: arrowdantic-0.2.1-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for arrowdantic-0.2.1-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 4da1a48ce09172826ab7a36957e674a15f606103571ee3214aef1db71c024211
MD5 5da76372360bd0c565e3dd7aec80c253
BLAKE2b-256 31082c4e459e0ced20e1405ef65588469ffa9c58d9d08f46c0c8d440bcf73372

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for arrowdantic-0.2.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7445f3bec6c0907e342dc8cc88e802fa08a13012939b2d696f03ce2da143077f
MD5 11e4b7ac8261ffcdf50fcf6c16ade8d5
BLAKE2b-256 02b498c573ad8adf8f792b12f043e2166132f7e2db2f1332a0ff8b9889ce388a

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for arrowdantic-0.2.1-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0210b1bda9fb50fda85b5046ac2bf2d7bb506d23c5ceb323c161bd938fc1a66b
MD5 9110f7a835ffa58dd4d9ec820aeb06ca
BLAKE2b-256 e94694c98dbfb72e6e00fa48ed541e3acf587054e808782ca7e0cf21c7daf96b

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp39-none-win_amd64.whl.

File metadata

  • Download URL: arrowdantic-0.2.1-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for arrowdantic-0.2.1-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 ab34b5b19bb70bb7ac4400356f234a73c5405ccdaba971d4358aebfae81fba53
MD5 f9f6318d0c1f89c9a6365fa45ec1db03
BLAKE2b-256 bc6131e3d86834c3eddf267cd0811dec135820ffe21130e36d8440ee9c8508ea

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for arrowdantic-0.2.1-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 cc1dec6d51545cb3f69ca08edab28e6031a9fea59588c204cb6e8793214fe6b3
MD5 5c545bbcd19244cf7132cc1c50e1c1db
BLAKE2b-256 b62fae29542388ccfd501d4ab8d101a79574025fcbe328376e890654ac313b7e

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for arrowdantic-0.2.1-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 11846bdf7ccd35cf4fb4b007f620894f194d49877b09dd57eb53a6e702a73b66
MD5 5b7f0fff9a45b8fc14d8390cb1cdb8a6
BLAKE2b-256 0ae5b8d1c678fe61eac2b364271d4cf54db7ccedcf623cf30870cdf6ed067a5d

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp38-none-win_amd64.whl.

File metadata

  • Download URL: arrowdantic-0.2.1-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for arrowdantic-0.2.1-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 8002deeb1e4ce55ea19f7802fafba5635a7370aac1775620d2724dca98e7ead0
MD5 1575210e0b80976ebd6b17df56af14a0
BLAKE2b-256 54aa103586db482c361528402e5e59f048169b339a7fc07cc4c07c63ffad286a

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for arrowdantic-0.2.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2412ed19ab5c951afb5ba88a1dd4c851e977435d4d6a5ef431a083e57b2383b9
MD5 6bb0047c478b0c55e049db2620249eab
BLAKE2b-256 f54d19d57ae30d679b3ef6f1b23f2047321a5fad2dcd9291a27af33a27aa7971

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for arrowdantic-0.2.1-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0505e5fad8f73f6979836c841ab018868f3009584c65da250f8b970d3f162fb4
MD5 b0174f9216aa37e4821a67e0a718528d
BLAKE2b-256 3be6c8118a10231f15783bec48b4986a5dd62b081e3e2cae5eed3e0feecd77f4

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp37-none-win_amd64.whl.

File metadata

  • Download URL: arrowdantic-0.2.1-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for arrowdantic-0.2.1-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 e0002f9b5906594a181501852a9d7656b5baf044a4ffad56f0190ea9fe886111
MD5 5572b6a7963b8ff4885e792e463db75c
BLAKE2b-256 1a0c286650b6987f53e1376d4aae122ac0dc0485cb44944e06b62653df158f18

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for arrowdantic-0.2.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f06ee114765c50e138469c49c7247cd66013e78a26a40c65910f1d70d222525b
MD5 820f263a84d58d52b94c8c772c5b0f80
BLAKE2b-256 45821194d86506a8a8c3a13c9edc8cefe3fe33d9226773a194c628fc9efa3b37

See more details on using hashes here.

File details

Details for the file arrowdantic-0.2.1-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for arrowdantic-0.2.1-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 f66e6db34029e9df10696adc5a76416d0e81a9e7e36e0cfed942543d11035b27
MD5 b109d2a1bbdfeab3c0666d2f0dfa5ced
BLAKE2b-256 2ce4fccf24d12c5007ca6316743cf41cd0bde1248a7b2160580454937cf0173f

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