sql-inports
v1.0.2
Published
A simple pre-processor for building sql from multiple files.
Downloads
5
Maintainers
Readme
sql-inports
A simple pre-processor for building sql from multiple files.
To include a .sql
file:
-- @include ./path/to/file.sql
To include all .sql
files in a folder:
-- @include ./path/to/dir
example:
main.sql:
-- @include ./my_func.sql
select * from my_func();
my_func.sql:
create or replace function my_func() returns void as $$
declare
-- variables go here
begin
-- logic goes here
end;
$$ LANGUAGE plpgsql;
output.sql:
-- INCLUDE: ./my_func.sql
create or replace function my_func() returns void as $$
declare
-- variables go here
begin
-- logic goes here
end;
-- INCLUDE END;
select * from my_func();
file.js:
var fs = require('fs');
var compileSQL = require('sql-inports');
fs.writeFileSync('./output.sql', compileSQL('./main.sql'));