SQLite binary database format parser.
Homonym libraries:
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(())
} ```
References:
+---+-------+-----------+-----------+-----------+
| h | | | | |
| e | | | | |
| a | root | page 2 | ... | page N |
| d | page | | | |
| e | | | | |
| r | | | | |
+---+-------+-----------+-----------+-----------+
^ ^ ^
< page size | page size | page size | page size >
+---------------------+
| page header |
+---------------------+
| cell pointer array |
+---------------------+
| |
| unallocated space |
| |
+-------+-------------+
|cell N |free block |
+-------+------+------+
|cell 5 |cell 4|cell 3|
+-------+----+-+------+
| cell 2 | cell 1 |
+------------+--------+
Page types:
0x00
in header and the rest is payloadPage 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
+-----------+--------+--------+--------+-----+--------+-----------+-----+-----------+
|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 >