Crates.io | sqlite_parser |
lib.rs | sqlite_parser |
version | 0.1.20 |
source | src |
created_at | 2021-01-20 10:15:45.745732 |
updated_at | 2023-12-28 03:03:40.85942 |
description | Parse SQLite databases |
homepage | |
repository | https://github.com/Jasperav/SQLiteParser |
max_upload_size | |
id | 344341 |
size | 30,257 |
This crate will make it easy to parse a SQLite database. This can be useful for code generation.
Add a dependency on this crate by adding this line under [dependencies]
in your Cargo.toml
file:
sqlite_parser = "*"
Than implement the Parser
trait and call the parse
function with the implementing
struct
and the location of the SQLite file. There is a convenience method that doesn't require an implementing Parser
trait
called parse_no_parser
.
There are 2 ways of using this library
Parser
trait and call the parse
function.use sqlite_parser::{parse, Parser, Table, Metadata};
/// Create a parse struct to process the tables
/// Note: there is a convenience method `parse_no_parser` that doesn't require a parser.
struct Parse;
impl Parser for Parse {
fn process_tables(&mut self, meta_data: Metadata) {
// Do something with the tables
}
}
/// Start the parsing
parse(&my_sqlite_file_location, &mut Parse { });
Parser
trait and call the parse_no_parser
function.use sqlite_parser::parse_no_parser;
/// Start the parsing
let _tables = parse_no_parser(&my_sqlite_file_location);
/// Do stuff with the tables property!