SWAFQueries

SWAFQueries is a thin layer on top of Ecto and MyXQL driver that compiles raw SQL files into Elixir functions.

Installation

The package can be installed by adding swaf_queries to your list of dependencies in mix.exs:

 defp deps do
    [
      # {:swaf_views, path: "../swaf_queries"},
      {:swaf_queries, "~> 0.2"}
    ]
  end

See Hexdocs for a full documentation.

Features

SWAFQueries is based on Ecto which are fantastic pieces of code that implement many goodies. The main ones:

Todo

Interested to give a hand? Welcome, be my guest and contact me.

Known bugs to be corrected

Features

Motivation

My personal reason is that I don't like Ecto DSL. Please, understand me. Ecto is a great piece of code and SWAFQueries relies on it, but it's just too much for my needs. I'm not (any more) a professional developer and I'm working on one, maybe two side projects per year that require a database. Every time I try Ecto, I feel like I need to re-learn a new language, which means new syntax, debugging, etc. while the only thing I actually need to do is to send a SELECT or an INSERT to a database. Yet, I'm definitely not some kind of pro-pure-SQL extremist and I love having help from my development stack like connection management, security, optimization.

There are some other good and more general reasons to use SQL directly:

All that put together, I started to look around how the others were doing, to write some macros that inject helpers and it finished with SWAFQueries.

Sources of inspiration and alternatives