Package: reth-db-py
reth-db-pyPython 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.InstallationThis package has been published to PyPi and can be installed using pip:pipinstallreth-db-pyAssetsThis package only has a single python class made available:PyDatabaseHandler.PyDatabaseHandleris a class used to interact with the Reth DB.  It's a wrapper around the RustDatabaseHandlerstruct.
It has a few methods which all return json strings:get_header_by_block_number: get a single header by block numberget_headers_by_block_number_range: get multiple headers by block number rangeget_transaction_by_id: get a single transaction by transaction idget_transactions_by_id_range: get multiple transactions by transaction id rangeget_transactions_by_block_number_range: get multiple transactions by block number rangeget_block_by_number: get a single block by block numberget_uncles_by_block_number: get uncles by block numberget_receipts_by_transaction_id: get receipts by transaction idget_receipts_by_block_number: get receipts by block numberimplPyDatabaseHandler{pubfnget_header_by_block_number(&self,number:u64)->PyResult<String>pubfnget_headers_by_block_number_range(&self,start:u64,end:u64)->PyResult<String>pubfnget_transaction_by_id(&self,id:u64)->PyResult<String>pubfnget_transactions_by_id_range(&self,start:u64,end:u64)->PyResult<String>pubfnget_transactions_by_block_number_range(&self,start:u64,end:u64)->PyResult<String>pubfnget_block_by_number(&self,number:u64)->PyResult<String>pubfnget_uncles_by_block_number(&self,number:u64)->PyResult<String>pubfnget_receipts_by_transaction_id(&self,id:u64)->PyResult<String>pubfnget_receipts_by_block_number(&self,number:u64)->PyResult<String>}classPyDatabaseHandler:defget_header_by_block_number(self,number:int)->strdefget_headers_by_block_number_range(self,start:int,end:int)->strdefget_transaction_by_id(self,id:int)->strdefget_transactions_by_id_range(self,start:int,end:int)->strdefget_transactions_by_block_number_range(self,start:int,end:int)->strdefget_block_by_number(self,number:int)->strdefget_uncles_by_block_number(self,number:int)->strdefget_receipts_by_transaction_id(self,id:int)->strdefget_receipts_by_block_number(self,number:int)->strUsageImport reth-db-py assets:fromreth_db_pyimportPyDatabaseHandlerCreate a PyDatabaseHandler instance:handler=PyDatabaseHandler("/path/to/db/mdbx.dat")Get the header by block numberheader=handler.get_header_by_block_number(17_000_000)Get the headers by block number rangeheaders=handler.get_headers_by_block_number_range(17_000_000,17_000_005)Get transaction by idtransaction=handler.get_transaction_by_id(1000)Get transactions by id rangetransactions=handler.get_transactions_by_id_range(1000,1005)Get transactions by block number rangetransactions=handler.get_transactions_by_block_number_range(17_000_000,17_000_005)Get block by numberblock=handler.get_block_by_number(17_000_000)Get uncles by block numberuncles=handler.get_uncles_by_block_number(17_000_000)Get receipts by transaction idreceipts=handler.get_receipts_by_transaction_id(1000)Get receipts by block numberreceipts=handler.get_receipts_by_block_number(17_000_000)TestsComing soon.BenchmarksSpeed tests between RPC calls vs. reth-db-py calls (direct db interaction) coming soon.