Extended prepared statement
  • OCaml 96.2%
  • Makefile 3.8%
Find a file
2015-03-21 08:12:49 +09:00
emit.ml first commit 2015-03-20 21:10:49 +09:00
lexer.mll first commit 2015-03-20 21:10:49 +09:00
LICENSE first commit 2015-03-20 21:10:49 +09:00
main.ml safe close input channel 2015-03-21 08:12:49 +09:00
Makefile first commit 2015-03-20 21:10:49 +09:00
parser.mly first commit 2015-03-20 21:10:49 +09:00
README.md Update README.md 2015-03-20 21:14:36 +09:00
test.sql first commit 2015-03-20 21:10:49 +09:00
types.ml first commit 2015-03-20 21:10:49 +09:00
utils.ml safe close input channel 2015-03-21 08:12:49 +09:00

eps

extended prepared statement language.

Summary

Labeled argument with type and default value are enabled in prepared statement.

/* test.sql */
prepare foo(age:int, name:text = "no name") as
select * from people where age = {age} and name = {name};

Output

You can output SQL or OCaml code.

1. SQL

/* eps.exe -input test.sql -format sql */
prepare foo(int, text) as select * from people where age = $1 and name = $2;

2. OCaml code

(* eps.exe -input test.sql -format ocaml *)

let prep_foo =
  "prepare foo(int, text) as select * from people where age = $1 and name = $2;"

let exec_foo ~age ?(name="no name") () =
  Printf.sprintf "execute foo(%d, '%s');" age name

Prerequisite

  1. OCaml(>= 3.12)
  2. pcre(pcre-ocaml)

Build

Just make and eps.exe is generated.

License

MIT