robinkanters / endo

Translates SQL to Ecto query

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Endo

Translates a SQL query to Ecto query syntax.

Examples:

iex> Endo.translate("SELECT * FROM Users WHERE age > 18")
"from u in User, where: u.age > 18, select: u"

or

iex> Endo.translate("SELECT * FROM Users WHERE age > 18")
"Users |> where([u], u.age > 18)

Installation

  1. Add endo to your list of dependencies in mix.exs:
def deps do
  [{:endo, "~> 0.1.0"}]
end
  1. Ensure endo is started before your application:
def application do
  [applications: [:endo]]
end

The Big Idea

I want to create a library that takes input SQL, Cypher, MongoDB, etc. and convert it to libraries specific syntax like Ecto, Arel and ActiveRecord.

This will be a great educational tool for developers that know how to write a SQL query but don't know how to covert it to that specific library.

My goal is to make it extendible so other libraries can easily be added. I want to reach this by converting the input to a AST/CST.

I got this inspiration from http://scuttle.io where you can convert SQL to Arel.

Usefull links

Ecto syntax examples: http://www.glydergun.com/the-ecto-query-library/

About

Translates SQL to Ecto query


Languages

Language:Elixir 100.0%