tsq

tsqlreader

πŸ“ˆ load queries from .sql-files + naming + tamplates

Showing:

Popularity

Downloads/wk

3

GitHub Stars

0

Maintenance

Last Commit

5yrs ago

Contributors

1

Package

Dependencies

0

Size (min+gzip)

0.8KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

#tsqlreader

Load SQL-queries from a file. Inside the file you write multiple queries like that in a file:

sql someName
    SELECT * from something;
end
#some comment
/* 
multiline
comment
*/
// rest of line comment
sql queryUsingFragment
    SELECT ${fragment} from ${prefix}something
end

sql fragment
    fieldOne as f, fieldtwo as fieldtwo
end

As you see, this small lib supports commets and fragments in a simple format.

var sqlreader = require('tsqlreader');
var initialFragments = {
    prefix: 'wp_'
};
var queries = sqlreader.parseSQLFileSync('queries/domain.sql',initialFragments);

mysql.query(queries.myQuery,params,callback);

for now this is all you need. the path, provided can be absolute, or relative to the current file or relative to process.cwd().

InitialFragments is an optional parameter, to predefine fragmets. In this case, it is used to provide a prefix for the table.

Motivation

Developer

Tobias Nickel German software developer in Shanghai. alt text

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100