:py:mod:`dissect.database.bsd.db` ================================= .. py:module:: dissect.database.bsd.db Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.database.bsd.db.DB dissect.database.bsd.db.Page Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.database.bsd.db.overflow_data dissect.database.bsd.db.BS_TO_PAGE dissect.database.bsd.db.BUCKET_TO_PAGE Attributes ~~~~~~~~~~ .. autoapisummary:: dissect.database.bsd.db.DBT .. py:data:: DBT An internal page entry structure + data (loosely related to Data-Base Thang). .. py:class:: DB(fh: BinaryIO) Berkeley DB. :param fh: File-like object containing the Berkeley DB data. .. py:attribute:: fh .. py:attribute:: page_size .. py:attribute:: page .. py:property:: is_btree :type: bool Return whether the database of a ``DB_BTREE`` type. .. py:property:: is_recno :type: bool Return whether the database is a ``DB_RECNO`` type. .. py:property:: is_hash :type: bool Return whether the database is a ``DB_HASH`` type. .. py:method:: records() -> collections.abc.Iterator[tuple[bytes | int, bytes]] Iterate over all records in the database. .. py:class:: Page(db: DB, pgno: int) A single page in a Berkeley DB. :param db: The parent ``DB`` instance. :param pgno: The page number to load. .. py:attribute:: db .. py:attribute:: pgno .. py:attribute:: offset .. py:property:: raw :type: bytes Raw page data. .. py:property:: data :type: memoryview Page data, excluding any overhead (headers). .. py:property:: header :type: dissect.database.bsd.c_db.c_db.PAGE Page header. .. py:property:: type :type: int Page type. .. py:property:: lookup :type: list[int] List of offsets to entries in the page. .. py:method:: entry(index: int) -> DBT Get a single entry by index. Type depends on page type. Also returns the associated data (DBT, Data-Base Thang, or key/data buffer) if applicable. .. rubric:: References - ``__db_ret`` :param index: Index of the entry to retrieve. .. py:method:: entries() -> collections.abc.Iterator[DBT] Iterate over all entries in the page. .. py:function:: overflow_data(db: DB, pgno: int, size: int) -> bytes Get off-page data. .. rubric:: References - ``__db_goff`` :param db: The parent ``DB`` instance. :param pgno: The starting page number of the overflow data. :param size: The total size of the overflow data to read. .. py:function:: BS_TO_PAGE(bucket: int, spares: list[int]) -> int .. py:function:: BUCKET_TO_PAGE(db: DB, bucket: int) -> int