Translates a SQL query to Ecto query syntax.
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)
- Add
endo
to your list of dependencies inmix.exs
:
def deps do
[{:endo, "~> 0.1.0"}]
end
- Ensure
endo
is started before your application:
def application do
[applications: [:endo]]
end
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.
Ecto syntax examples: http://www.glydergun.com/the-ecto-query-library/