sql-inports

1.0.2 • Public • Published

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'));

Package Sidebar

Install

npm i sql-inports

Weekly Downloads

3

Version

1.0.2

License

MIT

Last publish

Collaborators

  • mike96angelo