Add this line to your application's Gemfile:
gem 'candy--sql'
And then execute:
$ bundle
Or install it yourself as:
$ gem install candy--sql
$ bin/make sample/sample1.csql
You should make tables in your database before do sample queries. Please use sample/seed.sql
S-- *
F-- candies
O-- id
↓CandySql.make
SELECT *
FROM candies
ORDER BY id
S-- count(*)
F-- sales
W-- created_at >= '2015-01-01'
O-- created_at
↓CandySql.make
SELECT count(*)
FROM sales
WHERE created_at >= '2015-01-01'
ORDER BY created_at
SL== sales
CD== candies[CD.id = SL.candy_id]
S-- *, SL.num * CD.price
F-- SL =< CD
W-- CD.sweet > 2
O-- created_at
↓CandySql.make
SELECT *, SL.num * CD.price
FROM sales AS SL
INNER JOIN candies AS CD ON CD.id = SL.candy_id
WHERE CD.sweet > 2
ORDER BY created_at
Bug reports and pull requests are welcome on GitHub at https://github.com/llby/candy--sql.
The gem is available as open source under the terms of the MIT License.