Skip to main content

Read the data of an ODBC data source as sequence of Apache Arrow record batches.

Project description

arrow-odbc-py

Licence

Fill Apache Arrow arrays from ODBC data sources. This crate is build on top of the arrow Python package and arrow-odbc Rust crate and enables you to read the data of an ODBC data source as sequence of Apache Arrow record batches.

State

I am writing this mainly to learn how to exchange Arrow Arrays via the C Interface between Rust and Python. If you happen to know how this is supposed to work your review and contribution would be highly welcome (not that it wouldn't otherwise).

Users looking for a mature solution for bulk fetching data from ODBC data sources in Python should also take a look at turbodbc which has a helpful community and seen a lot more battle testing than this. Also this Python package is more narrow in Scope (which is a fancy way of saying it has less features), as it is only concerned with bulk fetching Arrow Arrays and nothing else.

About Arrow

Apache Arrow defines a language-independent columnar memory format for flat and hierarchical data, organized for efficient analytic operations on modern hardware like CPUs and GPUs. The Arrow memory format also supports zero-copy reads for lightning-fast data access without serialization overhead.

About ODBC

ODBC (Open DataBase Connectivity) is a standard which enables you to access data from a wide variaty of data sources using SQL.

Usage

from arrow_odbc import read_arrow_batches_from_odbc

connection_string="Driver={ODBC Driver 17 for SQL Server};Server=localhost;UID=SA;PWD=My@Test@Password1;"
query = f"SELECT * FROM MyTable"

reader = read_arrow_batches_from_odbc(
    query=query, batch_size=1000, connection_string=connection_string
)

for batch in reader:
    # Process arrow batches
    pass

Matching of ODBC to Arrow types

ODBC Arrow
Numeric(p <= 38) Decimal
Decimal(p <= 38) Decimal
Integer Int32
SmallInt Int16
Real Float32
Float(p <=24) Float32
Double Float64
Float(p > 24) Float64
Date Date32
LongVarbinary Binary
Timestamp(p = 0) TimestampSecond
Timestamp(p: 1..3) TimestampMilliSecond
Timestamp(p: 4..6) TimestampMicroSecond
Timestamp(p >= 7 ) TimestampNanoSecond
BigInt Int64
TinyInt Int8
Bit Boolean
Varbinary Binary
Binary FixedSizedBinary
All others Utf8

Project details


Release history Release notifications | RSS feed

This version

0.1.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arrow_odbc-0.1.2.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

arrow_odbc-0.1.2-py3-none-win_amd64.whl (530.6 kB view details)

Uploaded Python 3 Windows x86-64

File details

Details for the file arrow_odbc-0.1.2.tar.gz.

File metadata

  • Download URL: arrow_odbc-0.1.2.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.11.5

File hashes

Hashes for arrow_odbc-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c7867ee4aee1eb53816e805f0428bff5b06ac4d45f9c967e9490f1d5a8725873
MD5 eb667773b2e6894feb7a286c8c342ae7
BLAKE2b-256 d9609443961b69b39990839908ae847d4620d78713ca2749ad502a87463d2267

See more details on using hashes here.

File details

Details for the file arrow_odbc-0.1.2-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for arrow_odbc-0.1.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 cb75e11100c5c593cd514fa2362dac8161d3ba8ee1032075a8e214be98d4b468
MD5 613ae33b743ab2467b6ab2c5204658bb
BLAKE2b-256 c921688e70912b0bbdb6b4a31221617d2bcc32bdc534219f2fb964ebde936345

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page