Rewrite to use embed.FS and sqlx.

This commit is contained in:
2022-01-02 19:46:54 -08:00
parent ff130af80a
commit cae890c983
6 changed files with 133 additions and 18 deletions

View File

@ -1,2 +1,13 @@
# simplesql
simplesql is a Go library to simplify using prepared statements. It is built on top of [sqlx](https://jmoiron.github.io/sqlx/).
## Use
To use simplesql, embed a directory of files in a Go program. Call simplesql.Prepare with the embedded FS.
* The embedded directory is expected to be named "sqlq".
* Files must have the extension ".sql".
* Queries must be written using [named parameters](https://jmoiron.github.io/sqlx/#namedParams).
After calling Prepare successfully, a Stmts type is returned. This maps the file name to the prepared statement in the file.
See [the test package](./simplesql_test) for a working example.