Firebird News

Tuesday, March 27, 2012

Fire ruby - howto start with Firebird and Ruby on ubuntu / debian

This howto is about installing firebird ruby driver on Ubuntu (tested on natty) and Debian (tested on Sid)
you might need some firebird dependencies and if you need the stable Firebird server  Firebird 2.5 guide to install it

The very basic firebird package to build only the driver is firebird2.5-dev

sudo apt-get install firebird2.5-dev git-core
and choose yes when asked

if is already installed you will get :

firebird2.*-dev was already installed

Then you need to install ruby and rubygems , the recommended way is to use and install rvm


rvm install 1.9.3
rvm use 1.9.3

Best way is to install it from gem


gem install fb


Alternate way  is to build install our gem (latest build-able is located here )

git clone https://github.com/rowland/fb.git
cd fb/
gem build fb.gemspec

I could build only with gem 1.9.x (with gem 1.8 i have got this error undefined method `mark_version' for nil:NilClass )

You will get something like this in terminal :
Successfully built RubyGem
Name: fb
Version: 0.7.x
File: fb-0.7.x.gem


Now is time to install it using the gem command

gem install fb-0.7.*



Please read the README.
here is how i tested on my machine


I had to add require 'rubygems'
to the example from README and all was ok after that

Here is part of the example i ran on my pc

pico test.rb 


And here are the results for my ruby test
ruby test.rb 
ID: 0, Name: John 0
ID: 9, Name: John 9

What is next class ? RoR on Firebird

12 comments:

info said...

s.o.linux ubuntu server 9.0.4
firebird version 2.1.2.18118
rails 2.3.2
ruby 1.8.7 patchlevel 72
rake 0.8.5
fb_adapter 0.5.8
fb 0.5.9
passenger 2.2.2
nginx 0.6.36

query from isql
select sum(val_emessi) from g1_items where licence_id = 6 and tipogioco = 'SPORT QF' AND TIPO = 'A' AND DATA >= '2009/01/02' AND DATA <= '2009/01/02'

result => 2837.00 ....fine

query from rails

condizioni = "data >= '#{from_date}' and
data <= '#{to_date}' and
licence_id = '#{session[:licence_id]}' and
tipogioco = '#{tipogioco}' and
tipo = '#{modo}'"
@emessi = G1Item.sum('val_emessi', :conditions => condizioni)

result => 283700.00 .... error

In windows
activerecord-firebird-adapter (1.0.0.9250)
fireruby (0.4.3)
rails 2.3.2
firebird version 2.0.3.12981
work fine.

ciao...

mariuz said...

could you create an sql script , I want to test it myself and then debug it

mariuz said...

I see that wishdev does have some changes but i don't think it touches that area (I will check the changes )

http://github.com/wishdev

mariuz said...

seems to be fixed now in rowland/fb > 0.5.10 release http://github.com/rowland/fb/issues/closed/#issue/1/comment/46791

Che said...

Hi Mariuz! I am trying to run RoR with Firebird. When I tried the little test from your blog, I get an error message:
$ ruby test.rb
/usr/local/lib/site ruby/1.8/rubygems/custom_require.rb:31:in 'gem_original_require': no such file to load -- fb (LoadError)

It seems to be a problems with PATH, but I am not sure. Please, could you help me?
Thank you very much!
Luiz (Brasilia - Brazil)

mariuz said...

did you installed the firebird gem ?

sudo gem install fb-0.6.7.gem

Vikram Kumar Mishra said...

No firebird connection established.

firebird 2.5
rails 3.2.6
ruby 1.9.2
fb 0.6.9
fb_adapter 0.6.2
activerecord-fb-adapter 0.7.0

rake db:create gives the output
{:adapter=>"fb",
:database=>"localhost/3050:/var/lib/firebird/2.5/data/rubyonfire.fdb",
:username=>"sysdba",
:password=>"12345",
:host=>"localhost",
:downcase_names=>true}
{:adapter=>"fb",
:database=>"localhost/3050:/var/lib/firebird/2.5/data/rubyonfire_test.fdb",
:username=>"sysdba",
:password=>"12345",
:host=>"localhost",
:downcase_names=>true}

please help me

Vikram Kumar Mishra said...

No firebird connection established

I am getting above error while trying to connect my rails app with firebird.

I have followed your post and in my gemfile i have added

gem 'activerecord-fb-adapter'
gem 'fb'

my rails version is 3.2.6 and ruby version is 1.9.2.

Also i have cloned 'fb' and 'fb_adapter' in rails app root directory.

Please help me.

Adrian Marius Popa said...

Try the 0.7.0 version from gem
also i have updated the repository git instructions please use the new one because there are updates for rails 3.2.x

http://rubygems.org/gems/activerecord-fb-adapter

Adrian Marius Popa said...

See this issue Try adding "create: true" under your profile in database.yml.

https://github.com/rowland/activerecord-fb-adapter/issues/1#issuecomment-6608210

Adrian Marius Popa said...

Oh a i see that you have solved that issue and hit another one :)

Vikram Kumar Mishra said...

yes, can you suggest me something on the issue posted on github regarding execute method.