# Run an sql query

**URL:** <https://www.ruby-forum.com/t/run-an-sql-query/129522>\
**Category:** Rails\
**Created:** [February 19, 2008, 7:40am UTC](https://www.ruby-forum.com/t/run-an-sql-query/129522 "2008-02-19T07:40:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitjain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@amitjain](https://www.ruby-forum.com/u/amitjain)\
**Post date:** [February 19, 2008, 7:40am UTC](https://www.ruby-forum.com/t/run-an-sql-query/129522/1 "2008-02-19T07:40:05Z")

</div>

Hello All,

Iam new to Ruby on Rails. I am moving my application to Ruby on rails.  
Is there an way i can call C++ API from ruby, so that i dont have to do  
much porting on Ruby on Rails.

I have alread an DB and i want to just show only selected columns from  
one of the table. I am not getting how to write an sql query. Can any  
one help me in this regard.

Regards,  
Amit JAin

---

<div class="post-metadata">

**Author:** ![amitjain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@amitjain](https://www.ruby-forum.com/u/amitjain)\
**Post date:** [February 19, 2008, 8:26am UTC](https://www.ruby-forum.com/t/run-an-sql-query/129522/2 "2008-02-19T08:26:38Z")

</div>

hi amit …  
There is no any bridge available for c++ and ruby till…  
1 way is there you can convert your app to ror complete…  
pls refer this in case of any help

> **[Google Sites: Sign-in](https://accounts.google.com/v3/signin/identifier?dsh=S-670777592%3A1689026230641815&continue=https%3A%2F%2Fsites.google.com%2Fsite%2Fsites%2Fsystem%2Ferrors%2FWebspaceNotFound%3Fpath%3D%2Fsaurabhpurnaye%2F&followup=https%3A%2F%2Fsites.google.com%2Fsite%2Fsites%2Fsystem%2Ferrors%2FWebspaceNotFound%3Fpath%3D%2Fsaurabhpurnaye%2F&ifkv=AeDOFXjvFIzXDSJ1Xofe0XWCmOJ3AR6iCtx56RN2nIaDxv6b4TbFb90u-jVfZrJEmeaiDi1svPPAuA&passive=1209600&service=jotspot&flowName=WebLiteSignIn&flowEntry=ServiceLogin)**
>
> Access Google Sites with a personal Google account or Google Workspace account (for business use).

Regards  
Saurabh purnaye  
saurabh[dot]purnaye[at]gmail[dot]com

Amit Jain wrote:

> Hello All,
> 
> Iam new to Ruby on Rails. I am moving my application to Ruby on rails.  
> Is there an way i can call C++ API from ruby, so that i dont have to do  
> much porting on Ruby on Rails.
> 
> I have alread an DB and i want to just show only selected columns from  
> one of the table. I am not getting how to write an sql query. Can any  
> one help me in this regard.
> 
> Regards,  
> Amit JAin

---

<div class="post-metadata">

**Author:** ![amitjain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@amitjain](https://www.ruby-forum.com/u/amitjain)\
**Post date:** [February 19, 2008, 8:35am UTC](https://www.ruby-forum.com/t/run-an-sql-query/129522/3 "2008-02-19T08:35:55Z")

</div>

Saurabh P. wrote:

> hi amit …  
> There is no any bridge available for c++ and ruby till…  
> 1 way is there you can convert your app to ror complete…  
> pls refer this in case of any help  
> [http://saurabh.purnaye.googlepages.com](http://saurabh.purnaye.googlepages.com)  
> Regards  
> Saurabh purnaye  
> saurabh[dot]purnaye[at]gmail[dot]com
> 
> Amit Jain wrote:
> 
> > Hello All,
> > 
> > Iam new to Ruby on Rails. I am moving my application to Ruby on rails.  
> > Is there an way i can call C++ API from ruby, so that i dont have to do  
> > much porting on Ruby on Rails.
> > 
> > I have alread an DB and i want to just show only selected columns from  
> > one of the table. I am not getting how to write an sql query. Can any  
> > one help me in this regard.
> > 
> > Regards,  
> > Amit JAin

Hello Saurabh,

Thanks for replying me back.  
1 way is there you can convert your app to ror complete. How can i  
achieve this?  
I have added you on skype. i went thru site, but could not find. Can u  
send me the exact link.

Regards,  
Amit Jain

---

<div class="post-metadata">

**Author:** ![amitjain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@amitjain](https://www.ruby-forum.com/u/amitjain)\
**Post date:** [February 19, 2008, 12:50pm UTC](https://www.ruby-forum.com/t/run-an-sql-query/129522/4 "2008-02-19T12:50:47Z")

</div>

On 19 Feb 2008, at 07:26, Saurabh P. wrote:

> hi amit …  
> There is no any bridge available for c++ and ruby till…

Um you can quite easily write a ruby extension in c++. It’s really  
just the same as writing one in C (although there are some gotchas  
around exception handling, ruby exceptions not unwinding the c++ stack  
properly and things like that). We use several such extensions.

Fred

---

<div class="post-metadata">

**Author:** ![amitjain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@amitjain](https://www.ruby-forum.com/u/amitjain)\
**Post date:** [February 19, 2008, 2:38pm UTC](https://www.ruby-forum.com/t/run-an-sql-query/129522/5 "2008-02-19T14:38:44Z")

</div>

On 19 Feb 2008, at 13:35, Amit Jain wrote:

> > just the same as writing one in C (although there are some gotchas  
> > around exception handling, ruby exceptions not unwinding the c++  
> > stack  
> > properly and things like that). We use several such extensions.
> > 
> > Fred
> 
> Can you prvoide me some link or document where i can understand this  
> extensions?

Well there’s stuff in the pickaxe, and a quick search for ‘ruby c  
extension’ brings up stuff like  
[http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html](http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html)

---

<div class="post-metadata">

**Author:** ![amitjain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@amitjain](https://www.ruby-forum.com/u/amitjain)\
**Post date:** [February 19, 2008, 2:35pm UTC](https://www.ruby-forum.com/t/run-an-sql-query/129522/6 "2008-02-19T14:35:06Z")

</div>

Frederick C. wrote:

> On 19 Feb 2008, at 07:26, Saurabh P. wrote:
> 
> > hi amit …  
> > There is no any bridge available for c++ and ruby till…
> 
> Um you can quite easily write a ruby extension in c++. It’s really  
> just the same as writing one in C (although there are some gotchas  
> around exception handling, ruby exceptions not unwinding the c++ stack  
> properly and things like that). We use several such extensions.
> 
> Fred

Can you prvoide me some link or document where i can understand this  
extensions?

Regards,  
Amit Jain

---

<div class="post-metadata">

**Author:** ![amitjain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@amitjain](https://www.ruby-forum.com/u/amitjain)\
**Post date:** [February 19, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/run-an-sql-query/129522/7 "2008-02-19T17:13:14Z")

</div>

Carlson & Richardson’s “Ruby Cookbook” (O’Rielly) might be a good  
reference. They present a few different ways to ref a C-based API.

On Feb 19, 8:37 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
