How To Read ChiaDB #14233
SametBasturkk
started this conversation in
Support
How To Read ChiaDB
#14233
Replies: 1 comment 1 reply
-
You can check block_store.py for python code and SQL used for querying them. The code snippet pulled from my notebook below should help too. import zstd
@with_db_connection
async def get_block_bytes_by_height_async(
db, height: uint32
) -> Optional[str]:
query = f"SELECT block FROM full_blocks WHERE height=?"
async with db.execute(query, (height,)) as cursor:
row = await cursor.fetchone()
if row is not None:
block_bytes = zstd.decompress(row[0])
return block_bytes
else:
return None
async def get_block_by_height_async(height: uint32) -> Optional[FullBlock]:
block_bytes = await get_block_bytes_by_height_async(height)
if block_bytes is None:
return None
block = FullBlock.from_bytes(block_bytes)
return block |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to get some information from chiadb full_blocks block.
How can I read blob or buffer type of value at the chiadb?
Which path I should follow for convert to text or hex?
Byte32 > ? > ?
Beta Was this translation helpful? Give feedback.
All reactions