sqlite-parser-nom

SQLite binary database format parser.

Homonym libraries:

Usage

In your Cargo.toml:

toml [dependencies] sqlite-parser-nom = "0.1.0"

Load and parse file in memory:

```rust use sqliteparsernom;

fn main() -> Result<()> { let database = sqliteparsernom::open("database.sqlite3")?; println!("{}", database.pages.len());

Ok(())

} ```

SQLite format specification

References:

Physical structure

Database file

+---+-------+-----------+-----------+-----------+ | h | | | | | | e | | | | | | a | root | page 2 | ... | page N | | d | page | | | | | e | | | | | | r | | | | | +---+-------+-----------+-----------+-----------+ ^ ^ ^ < page size | page size | page size | page size >

Page

+---------------------+ | page header | +---------------------+ | cell pointer array | +---------------------+ | | | unallocated space | | | +-------+-------------+ |cell N |free block | +-------+------+------+ |cell 5 |cell 4|cell 3| +-------+----+-+------+ | cell 2 | cell 1 | +------------+--------+

Page types:

Page structure: - Cell pointer array grows from the top of the page to the bottom - Pointers are byte offsets within the page - Cells grow from the bottom of the page to the top

Cell

+-----------+--------+--------+--------+-----+--------+-----------+-----+-----------+ |Payload | | Header | Serial | | Serial | Data Cell | | Data Cell | |(Cell Size)| ... | Size | Type 1 | ... | Type N | Column 1 | ... | Column N | +-----------+--------+--------+--------+-----+--------+-----------+-----+-----------+ | | < cell header ^ record header ^ table row data > < cell size >