Expand description
rpsql preprocesses SQL files: variables, includes and comments.
A build starts at an entry point and runs in two passes. The first one applies the directives of every file, inlining the included files, so that the variables of a file are all known before any of them is used. The second one replaces the variable references that are left.
use rpsql::Builder;
let sql = Builder::new("main.sql").build()?;| Reference | Meaning |
|---|---|
@set name = value | sets a variable of the file |
@set global name = value | sets a variable of the global scope |
@unset name | removes a variable |
@include path | inlines a file, or the index.sql of a directory |
$name, ${name} | the value of a variable, \$ for a literal $ |
-- comment | a comment, the whole line is dropped |
Re-exports§
pub use actions::Action;pub use builder::Builder;pub use context::Context;pub use error::Error;pub use error::Position;pub use error::Result;pub use loader::Loader;pub use loader::load;pub use logger::Level;pub use scope::VariableScope;pub use writer::Writer;
Modules§
- actions
- The directive handlers of the preprocessor.
- builder
- Building an entry point into plain SQL.
- cli
- The command line interface.
- context
- The content of a file being preprocessed.
- error
- Errors produced while preprocessing a SQL file.
- loader
- Reading a file into a
Context. - logger
- A small logger that writes diagnostics to standard error.
- scope
- Variable scopes: one per file, plus a process wide global scope.
- writer
- Writing the preprocessed SQL to a file.
Constants§
- VERSION
- The version of the crate.