Skip to main content

Python wrapper around reth db. Written in Rust.

Project description

reth-db-py

Python package allowing you to interact with the Reth DB via Python. Written with Rust and Pyo3.

This python wrapper can access node data 15x-30x faster than local RPC calls. Using this package, the most recent block hash can be retrieved in ~100μs on a local reth DB.

Test Suite Py Versions Test OS

Installation

This package has been published to PyPi and can be installed using pip:

pip install reth-db-py

Assets

This package only has a single python class made available: PyDatabaseHandler.

PyDatabaseHandler is a class used to interact with the Reth DB. It's a wrapper around the Rust DatabaseHandler struct. It has a few methods which all return json strings:

  • get_header_by_block_number: get a single header by block number
  • get_headers_by_block_number_range: get multiple headers by block number range
  • get_transaction_by_id: get a single transaction by transaction id
  • get_transactions_by_id_range: get multiple transactions by transaction id range
  • get_transactions_by_block_number_range: get multiple transactions by block number range
  • get_block_by_number: get a single block by block number
  • get_uncles_by_block_number: get uncles by block number
  • get_receipts_by_transaction_id: get receipts by transaction id
  • get_receipts_by_block_number: get receipts by block number
impl PyDatabaseHandler {
    pub fn get_header_by_block_number(&self, number: u64) -> PyResult<String>
    pub fn get_headers_by_block_number_range(&self, start: u64, end: u64) -> PyResult<String>
    pub fn get_transaction_by_id(&self, id: u64) -> PyResult<String>
    pub fn get_transactions_by_id_range(&self, start: u64, end: u64) -> PyResult<String>
    pub fn get_transactions_by_block_number_range(&self, start: u64, end: u64) -> PyResult<String>
    pub fn get_block_by_number(&self, number: u64) -> PyResult<String>
    pub fn get_uncles_by_block_number(&self, number: u64) -> PyResult<String>
    pub fn get_receipts_by_transaction_id(&self, id: u64) -> PyResult<String>
    pub fn get_receipts_by_block_number(&self, number: u64) -> PyResult<String>
}
class PyDatabaseHandler:
    def get_header_by_block_number(self, number: int) -> str
    def get_headers_by_block_number_range(self, start: int, end: int) -> str
    def get_transaction_by_id(self, id: int) -> str
    def get_transactions_by_id_range(self, start: int, end: int) -> str
    def get_transactions_by_block_number_range(self, start: int, end: int) -> str
    def get_block_by_number(self, number: int) -> str
    def get_uncles_by_block_number(self, number: int) -> str
    def get_receipts_by_transaction_id(self, id: int) -> str
    def get_receipts_by_block_number(self, number: int) -> str

Usage

Import reth-db-py assets:

from reth_db_py import PyDatabaseHandler

Create a PyDatabaseHandler instance:

handler = PyDatabaseHandler("/path/to/db/mdbx.dat")

Get the header by block number

header = handler.get_header_by_block_number(17_000_000)

Get the headers by block number range

headers = handler.get_headers_by_block_number_range(17_000_000, 17_000_005)

Get transaction by id

transaction = handler.get_transaction_by_id(1000)

Get transactions by id range

transactions = handler.get_transactions_by_id_range(1000, 1005)

Get transactions by block number range

transactions = handler.get_transactions_by_block_number_range(17_000_000, 17_000_005)

Get block by number

block = handler.get_block_by_number(17_000_000)

Get uncles by block number

uncles = handler.get_uncles_by_block_number(17_000_000)

Get receipts by transaction id

receipts = handler.get_receipts_by_transaction_id(1000)

Get receipts by block number

receipts = handler.get_receipts_by_block_number(17_000_000)

Tests

Coming soon.

Benchmarks

Speed tests between RPC calls vs. reth-db-py calls (direct db interaction) coming soon.

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

reth_db_py-0.1.4.tar.gz (28.3 kB view details)

Uploaded Source

Built Distributions

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

reth_db_py-0.1.4-cp311-cp311-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

reth_db_py-0.1.4-cp311-cp311-macosx_10_7_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 10.7+ x86-64

reth_db_py-0.1.4-cp310-cp310-manylinux_2_34_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

reth_db_py-0.1.4-cp310-cp310-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

reth_db_py-0.1.4-cp310-cp310-macosx_10_7_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10macOS 10.7+ x86-64

reth_db_py-0.1.4-cp39-cp39-manylinux_2_34_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

reth_db_py-0.1.4-cp39-cp39-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

reth_db_py-0.1.4-cp39-cp39-macosx_10_7_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 10.7+ x86-64

reth_db_py-0.1.4-cp38-cp38-manylinux_2_34_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

reth_db_py-0.1.4-cp38-cp38-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

reth_db_py-0.1.4-cp38-cp38-macosx_10_7_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8macOS 10.7+ x86-64

reth_db_py-0.1.4-cp37-cp37m-manylinux_2_34_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.34+ x86-64

reth_db_py-0.1.4-cp37-cp37m-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.7mmacOS 11.0+ ARM64

reth_db_py-0.1.4-cp37-cp37m-macosx_10_7_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.7mmacOS 10.7+ x86-64

File details

Details for the file reth_db_py-0.1.4.tar.gz.

File metadata

  • Download URL: reth_db_py-0.1.4.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for reth_db_py-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e4a70a5b62009e355045db76b150a7ae359b90d91fd2601a46c445d66c845c0c
MD5 d8ba21cc4fba9565420514fcd08001a1
BLAKE2b-256 a7a3a71a56215e75d5bce1337e15eee7762edc07377c4725666e63232724bc9c

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30255760cb3fbfe2b5905f63fc5719f178205962d29fb756c5faa6a1f4f667b0
MD5 23742009e76f30eb1e4db869fa0c162d
BLAKE2b-256 e85d26dff4e8a53dcb1a82ccc4ab041a29c8f37e779e644996f10b987fbda8f7

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp311-cp311-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 f2d93f25c4ffa0266f74b66b8587b7a3541ceb02ffa85d885b57e5e4ff4e44a3
MD5 20af02ba170a0a2ba33f3013fd1dcd1e
BLAKE2b-256 0dd585ebd55028833ea15c16d69504973bd48b4c723803d07ad035bfd9b232cc

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a275607b6a0d226edf919f9c557cea8fc886e9e61bafa36bf9a6547507cb5ad5
MD5 9cf716cd9f990e5a7307463c1c480a55
BLAKE2b-256 53357b5537ed720243162fa2d6169357a927aecb2faf3dd0eae2f14ae000936d

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f97d42f948b3f2fb545f0616f0d193305a32b7e0e7eacea31d1c270238efc21
MD5 c3fba43d73e871fbbfa7d8da88bc1a77
BLAKE2b-256 7eda8699430bcb101ed3ba81a8efd02d1d21ea5218c4c83708da134ab8fb8500

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 1924b15bdf39248622301fd4e2b7dff10b0ce7c04380ba7e2e065901ab59234d
MD5 468ec33bc028b0a3bc72d7c1ef1c25da
BLAKE2b-256 f53a865acc1c24d43f5fcacf18237e389db955705eb93b5e093045c3c7cadb37

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b50b6577b161b843a8f779c67498b1706bb6f7b727d0712a72fdb28d5d381961
MD5 7c38056f572cccd477aa6e29ce1d9a58
BLAKE2b-256 c24a1d98f3863dc2fbc8e6a88b76005cea6f7791ef75c1d02044b23045b08fb1

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 023a559be76eb6c1f460649fc9b605802df9fabe94e7207e05566c789c059dd1
MD5 a2f845c36ed657bebc7ca0575ed949eb
BLAKE2b-256 f7dda45afce3d10c4ea02d5f54cd0e2f1c6412ce9dbb79b681ca1f6115067b81

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 44df501bc6a897258120503cb044420c37db4d472dfa3598e77ce668d65bb6dc
MD5 49d4540141f562cd8a3b703dcea23029
BLAKE2b-256 a33333fa8362adf0d142a16640eb0dbd9ea349576376bf94f8ecc97d597ab010

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f83c8c738144d6702fefebcd1d767c1a6956197242937f1aaa6bea3e1ef949f4
MD5 b69d99f81cbc673c4eb747448ac0ccf3
BLAKE2b-256 fdb0f87d2a563bf18a2d3deb64c7801448b26323fc1102015c698599bd29211f

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 11c498a17173db721327999792c453fb17b0581b823d5116b34a697bb951a344
MD5 fe348baefc62513a83d0ff3b16d2b348
BLAKE2b-256 c006af7e2810f340678b624809c5536e6a126e150b5e7d74ab27468020d333c4

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0dbd98a25b05c8b2ac3918573e8a74eff925454ed90fa1df4328c788c0bd0547
MD5 69700578095073bcae4bfda5ba6f492e
BLAKE2b-256 7f693bb1f5f9bbbd908e26201a4161f1537a5270389e18aeb81245af141445cd

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp37-cp37m-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp37-cp37m-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d4c42d069495d99feb7a3588bfe71d0f26713aabd9fa9d82a4c23b6f9ea9cf0f
MD5 ad4783ca47421338872d903d43d523d0
BLAKE2b-256 8fd093502dbd001986bd45abd7ab6d4c9cbabad2a4bbd612f5243103d0be953a

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp37-cp37m-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp37-cp37m-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 79c723a5660674919789ac10ddb4c32f1775b9dec54db75807a736fd0e89698f
MD5 58b1e916b9fd58df1498236b7a8b6007
BLAKE2b-256 1d51e6dc22fbf29dde79fd7799f86c2b2d32afdf75ac05fae2b11d7d90e12781

See more details on using hashes here.

File details

Details for the file reth_db_py-0.1.4-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for reth_db_py-0.1.4-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 78774323755be1c121ee62ae069c48e75b1121abae2f3f990b6d68ebfa5ecdef
MD5 1438ba6e3fdcd495b92abea7579eddf6
BLAKE2b-256 376b04d73ebacdf7c23b9e2b01ce92da0b4f82c385c06c6d57face2ca71244ca

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