---
title: "Discussion on \"Querying raw SQL with Elixir and Ecto\" | Hashnode"
description: "Discussion on \"Querying raw SQL with Elixir and Ecto\". TL;DR:\nalias MyApp.{Repo, Animal}\n\nsql = \"SELECT * FROM animals WHERE legs > $1\"\nparams = [2]\n\n%{rows: rows, columns: columns} = Repo.query!(sql, params)\n\nEnum.map(rows, fn row -> Repo.load(Animal, {columns, row}) end)\n\nIt was surprisingly difficult ..."
url: "https://hashnode.com/posts/querying-raw-sql-with-elixir-and-ecto/640968ba074385e19bc23e9e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Querying raw SQL with Elixir and Ecto](https://ozzie.sh/querying-raw-sql-with-elixir-and-ecto?utm_source=hashnode&utm_medium=feed)

TL;DR: alias MyApp.{Repo, Animal} sql = "SELECT \* FROM animals WHERE legs > $1" params = \[2\] %{rows: rows, columns: columns} = Repo.query!(sql, params) Enum.map(rows, fn row -> Repo.load(Animal, {columns, row}) end) It was surprisingly difficult ...

Mar 9, 2023 · 1 min read · ozzie.sh  
Read the article

-   [#elixir](https://hashnode.com/tag/elixir)
-   [#phoenix](https://hashnode.com/tag/phoenix)

## Written by

[Ozzie Neher](https://hashnode.com/@ozziexsh)

@ozziexsh · Saskatoon, SK, Canada

  
[View profile](https://hashnode.com/@ozziexsh)

Full Stack Dev

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
