Skip to main content

Crate rpsql

Crate rpsql 

Source
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()?;
ReferenceMeaning
@set name = valuesets a variable of the file
@set global name = valuesets a variable of the global scope
@unset nameremoves a variable
@include pathinlines a file, or the index.sql of a directory
$name, ${name}the value of a variable, \$ for a literal $
-- commenta 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.