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
- Implement the 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 processtables(&mut self, metadata: Metadata) { // Do something with the tables } }
/// Start the parsing parse(&mysqlitefile_location, &mut Parse { }); ```
Parser
trait and call the parse_no_parser
function.
```
use sqliteparser::parseno_parser;/// Start the parsing let tables = parsenoparser(&mysqlitefilelocation); /// Do stuff with the tables property! ```