spgen
v0.2.1
Published
Stored Procedure Generator to write like JavaScript
Downloads
58
Maintainers
Readme
spgen - A Stored Procedure Generater to write like JavaScript
Spgen is a tool for creating stored procedures like Javascript.
Example
// type.jssp
type IdentifierUser varchar(8);
// queries.jssp
query selectUser(userId) {
select count(*) from user
where user_id = :userId;
}
// import.jssp
import "./type.jssp"
import "./queries.jssp"
use test;
func demoimport(userId IdentifierUser) : int
{
selectUser('primespace');
return 0;
}
// generate stored procedure.
spgen generate import.jssp;
use test;
DELIMITER $$
DROP FUNCTION IF EXISTS demoimport;
CREATE FUNCTION demoimport(userId VARCHAR(8)) RETURNS INT
BEGIN
select count(*) from user
where user_id = 'primespace';
return 0;
END
$$
DELIMITER ;
Install
$ npm install -g spgen
spgen depends on Node.js and npm.
Usage
Usage: spgen <command>
where <command> is one of:
generate, get, version
spgen generate sample.jssp [-out <path>]
Converts the sample.jssp into the <path> directory
spgen get samples
Copy all sample files to the current directory.
spgen version
Output the version.
// Copy all sample files to the current directory.
$ spgen get samples
Generate stored procedure
// Converts the cursor.jssp into the output directory
$ spgen generate cursor.jssp -out ./output