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 pyarrow 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.

Compatibility

Should work with any Python 3.x and any Arrow version recent enough to support the Arrow C-Interface.

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

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.5.tar.gz (12.7 kB view details)

Uploaded Source

Built Distributions

arrow_odbc-0.1.5-py3-none-win_amd64.whl (319.6 kB view details)

Uploaded Python 3 Windows x86-64

arrow_odbc-0.1.5-py3-none-macosx_10_7_x86_64.whl (469.4 kB view details)

Uploaded Python 3 macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: arrow_odbc-0.1.5.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for arrow_odbc-0.1.5.tar.gz
Algorithm Hash digest
SHA256 e9652d5c15b2d128105858b48c32de7d522ce349691d7988aa3218a213a82e4f
MD5 2ce37b3424cc643701d5f4e2226ea28e
BLAKE2b-256 77b0008271f56c290aa1b05d4f314f1d94e1bbfde26b1fce6b326c781906c3ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arrow_odbc-0.1.5-py3-none-win_amd64.whl
  • Upload date:
  • Size: 319.6 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for arrow_odbc-0.1.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 28f8fd4883bee688946c59e7d75ae6629564cbcaa8434761b029f7ada5e67e90
MD5 96d4a4063781f41b1e7c3a636b62a186
BLAKE2b-256 e5d2a1cf02ee3cd70b5ef5f9063557b044a36f7679d95e03f354374c910fe207

See more details on using hashes here.

File details

Details for the file arrow_odbc-0.1.5-py3-none-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: arrow_odbc-0.1.5-py3-none-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 469.4 kB
  • Tags: Python 3, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for arrow_odbc-0.1.5-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0ca440e6a112ad72bc4e8d41f936ececc82eb7fe4642b6136e914ac6b9a6df30
MD5 6593a4478996a05e63565bd8d61dc623
BLAKE2b-256 4fd7b8601689b800be91ab66ad0892e545348e4d3106aa93a9858b460cefe853

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