Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 91fd7d1

Browse files
authored
Merge pull request #50 from zodiac/bind-option
Document `bind` option
2 parents 9a8c2ae + 36d8a0b commit 91fd7d1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ end)
3232
# => [%{id: 1, name: "Mikey", created_at: {{2012,10,14},{05,46,28}}, updated_at: {{2013,09,06},{22,29,36}}, type: nil}]
3333
```
3434

35+
Pass the `bind` option to bind parameterized queries.
36+
37+
```elixir
38+
Sqlitex.with_db('test/fixtures/golfscores.sqlite3', fn(db) ->
39+
Sqlitex.query(
40+
db,
41+
"INSERT INTO players (name, created_at, updated_at) VALUES ($1, $2, $3, $4)",
42+
bind: ['Mikey', '2012-10-14 05:46:28.318107', '2013-09-06 22:29:36.610911'])
43+
end)
44+
# => [[id: 1, name: "Mikey", created_at: {{2012,10,14},{05,46,28}}, updated_at: {{2013,09,06},{22,29,36}}, type: nil]]
45+
46+
```
47+
3548
If you want to keep the database open during the lifetime of your project you can use the `Sqlitex.Server` GenServer module.
3649
Here's a sample from a phoenix projects main supervisor definition.
3750
```elixir

0 commit comments

Comments
 (0)