You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A SQL toolkit for Elixir with automatic result transformation to maps and structs.
5
+
Execute raw SQL using files or strings, automatically get maps and structs back. Built on top of ecto_sql.
6
6
7
-
SqlKit provides two ways to execute raw SQL with results automatically transformed into maps or structs:
7
+
SqlKit provides two ways to execute raw SQL with automatic result transformation:
8
8
9
9
1.**Direct SQL execution** - Execute SQL strings directly with any Ecto repo
10
10
2.**File-based SQL** - Keep SQL in dedicated files with compile-time embedding
@@ -19,6 +19,7 @@ For file-based SQL, keeping queries in dedicated `.sql` files brings practical b
19
19
20
20
## Features
21
21
22
+
-**Just SQL**: No DSL or special syntax to learn.
22
23
-**Automatic result transformation**: Query results returned as maps or structs, not raw columns/rows
23
24
-**Two APIs**: Execute SQL strings directly or load from files
24
25
-**Compile-time embedding**: File-based SQL read once at compile time and stored as module attributes
@@ -82,7 +83,7 @@ For larger queries or better organization, keep SQL in dedicated files:
82
83
83
84
#### 1. Create SQL files
84
85
85
-
SQL files are housed in subdirectories under the root SQL directory. This is `priv/repo/sql` by default but is configurable via `:root_sql_dir` config option.
86
+
SQL files are housed in subdirectories under the root SQL directory. This is `priv/repo/sql` by default but is configurable via `:root_sql_dir` config option. The `priv/` directory is recommended because these files are included in Mix releases by default.
86
87
87
88
```sql
88
89
-- priv/repo/sql/reports/stats.sql
@@ -143,6 +144,61 @@ config :my_app, SqlKit,
143
144
load_sql::compiled# use compile-time embedded SQL
144
145
```
145
146
147
+
## Parameter Syntax by Database
148
+
149
+
Each database uses different parameter placeholder syntax:
0 commit comments