https://github.com/zweifisch/querykit
https://github.com/zweifisch/querykit
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zweifisch/querykit
- Owner: zweifisch
- Created: 2025-05-17T08:41:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-17T13:18:31.000Z (about 1 year ago)
- Last Synced: 2025-10-20T02:27:14.192Z (9 months ago)
- Language: Elixir
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Querykit
Querykit is a lightweight Elixir library that provides safe SQL query interpolation through a convenient sigil-based syntax. It automatically handles parameter binding to help prevent SQL injection while maintaining readable query syntax.
## Installation
Add `querykit` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:querykit, "~> 0.2.0"}
]
end
```
## Usage
Import Querykit in your module:
```elixir
import Querykit
```
Query with parameters:
```elixir
~q(SELECT * FROM users WHERE id = #{id})
# {"SELECT * FROM users WHERE id = $1", [id]}
```
Ecto schema support:
```elixir
~q"SELECT * FROM #{User} WHERE active = #{1}"
# {"SELECT * FROM users WHERE active = $1", [1]}
```