Git Product home page Git Product logo

relation's Introduction

Relation C Library

Description

Relation is is a Relational Algebra made in C language.

Based on Arel, Sequel and DataMapper.

Why I'm creating this library:

  • I want to learn C language and how create Wrappers to other languages, like Ruby and Python! (and this is a better way to do it! I think)

Actual Results

Ruby Wrapper

In order to create:

SELECT * FROM users

you create a Table object:

 users = Relation::Table('users')
 
 users.select('*').to_sql
 => "SELECT * FROM users"

A little more complexity

Using where operator:

 users.select('name').where("name = 'tomas'").to_sql
 => "SELECT name FROM users WHERE name = 'tomas'"

Using LIMIT or OFFSET:

 users.select('*').limit(10).to_sql
 => "SELECT * FROM users LIMIT 10"

 users.select('*').offset(10).to_sql
 => "SELECT * FROM users OFFSET 10"

Using ORDER BY as #order:

 users.select('*').order('name')
 => "SELECT * FROM users ORDER BY name"

Using GROUP BY as #group (like Arel):

users.select('*').group('name')
=> "SELECT * FROM users GROUP BY name"

Using HAVING as #having:

 users.select('name').group('name').having('age = 21').to_sql
 => "SELECT name FROM users GROUP BY name HAVING age = 21"

Benchmarks

Benchmarks Ruby Wrapper

Some LITTLE benchmarking about the actual results:

https://gist.github.com/705274

Running Tests

Just type in the root folder:

rake test

Pull Request

  • Don't forget about testing! =-)

relation's People

Contributors

arthurmm avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.