Documentation ¶
Overview ¶
Package qry is a general purpose library for storing your raw database queries in .sql files with all benefits of modern IDEs, instead of strings and constants in the code, and using them in an easy way inside your application with all the profit of compile time constants.
qry recursively loads all .sql files from a specified folder, parses them according to predefined rules and returns a reusable object, which is actually just a `map[string]string` with some sugar. Multiple queries inside a single file are separated with standard SQL comment syntax: `-- qry: QueryName`. A `QueryName` must match `[A-Za-z_]+`.
gen tool is used for automatic generation of constants for all user specified `query_names`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDirSql is returned in case when directory with .sql files is unavailable ErrDirSql = errors.New("cannot find directory with .sql files") // ErrDirPkg is returned in case when directory with go package is unavailable ErrDirPkg = errors.New("cannot find go package directory") )
Functions ¶
Types ¶
type File ¶ added in v1.1.0
File represents parsed file with .sql queries
func DirOrdered ¶ added in v1.1.0
DirOrdered recursively loads all .sql files from a specified folder and returns them as a slice