Read the data of an ODBC data source as sequence of Apache Arrow record batches.
Project description
arrow-odbc-py
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
Built Distributions
File details
Details for the file arrow_odbc-0.1.4.tar.gz
.
File metadata
- Download URL: arrow_odbc-0.1.4.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 397cd71af111a43272364192bb8d96720aa46e1ba6f69d32ec0c7cd48cf5fac7 |
|
MD5 | 80571a2a4b89c8f1927501bd80c607f7 |
|
BLAKE2b-256 | e2ac69a25d5942c2bb5cedda020994a3a9e286df146d5fbfdefcb3ab28c64a94 |
File details
Details for the file arrow_odbc-0.1.4-py3-none-win_amd64.whl
.
File metadata
- Download URL: arrow_odbc-0.1.4-py3-none-win_amd64.whl
- Upload date:
- Size: 316.9 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8e073cde5adfa37a6bb759c9098890d6f39ad183e3bc5717be43071a5b232bf |
|
MD5 | 9edf2e5ccb0114a30257c2363477f325 |
|
BLAKE2b-256 | 1b60d12e4fba869edb693d131e4f4061752cd99cd2b9db129c808f3fc67f4c7f |
File details
Details for the file arrow_odbc-0.1.4-py3-none-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: arrow_odbc-0.1.4-py3-none-macosx_10_7_x86_64.whl
- Upload date:
- Size: 992.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75d89aef987ded047e761136239b815feecf44bcf358856949cba29ce10df9f2 |
|
MD5 | a42bce821f4b040522c8c95a1398e523 |
|
BLAKE2b-256 | 509bb31c4e9387eb817acbd6fd88677097e70fb6309acccace8344f4771cae15 |