ToC

Thesis

SQL is complex language. There are variety of weird cases when you will be
not satisfied with query, generated by any tool. Sophisticated tools aimed
to hide this complexity and eventually became as complex as SQL itself and even
more: they substitute well defined SQL by vague DSL, add caching layers, do
fancy type conversions.

Goals of this library:

to cover most basic cases;

to give you an ability to adjust generated query;

to be embeddable into other libraries;

to be vendor agnostic(generated SQL is good for any RDBMS, but could be tuned to
match yours).

Usage

Suppose that we have table books in our SQL db:

Column

Type

Attributes

id

int

Primary key, read only

isbn

varchar

title

varchar

author

varchar

created

timestamp

Read-only

To begin to use mekao you'll need couple of things:

make a record with same fields as in SQL table you are interested in;

describe table in terms of mekao;

write some general settings for all queries (like how exactly LIMIT queries
are constructed for your RDBMS dialect, or how placeholders are looks like for
you DB driver).

This instructs mekao that you don't want to include other fields in query.

You may wonder about iolist_to_binary/1 trick. All queries generated by
mekao have a type iodata(). This means there could be mixed strings,
binaries, chars, nested lists of strings and so on. Some drivers do accept
iodata(), others do not. This made in the sake of performance, it is up to
application to convert this to any acceptable form.

Placeholders $1 and $2 were generated with help of user-defined
#mekao_settings.placeholder function.

If you want to extend resulted query use mekao:prepare_* set of queries
instead.

Install

Project follows SemVer versioning conventions. Backward
incompatible changes will result in a new branch, named after MAJOR version,
i.e. v0, v1, v2 and so on. Make sure that your project depends
on particular branch and not on master.