# Db4o oo database for ruby?

**URL:** <https://www.ruby-forum.com/t/db4o-oo-database-for-ruby/118705>\
**Category:** Ruby\
**Created:** [October 30, 2007, 9:11am UTC](https://www.ruby-forum.com/t/db4o-oo-database-for-ruby/118705 "2007-10-30T09:11:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerpux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/df788c/32.png) [@gerpux](https://www.ruby-forum.com/u/gerpux)\
**Post date:** [October 30, 2007, 9:11am UTC](https://www.ruby-forum.com/t/db4o-oo-database-for-ruby/118705/1 "2007-10-30T09:11:54Z")

</div>

Hi!

I saw that the guys at db4o support ruby to some degree and I wanted  
to know if anyone tried the db under ruby. Is this functional?  
[http://developer.db4o.com/ProjectSpaces/view.aspx/Tools\_And\_Add-Ons/Language\_Bindings\_or\_Implementations](http://developer.db4o.com/ProjectSpaces/view.aspx/Tools_And_Add-Ons/Language_Bindings_or_Implementations)  
(project db4ro)

Best regards and thx!

---

<div class="post-metadata">

**Author:** ![gerpux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/df788c/32.png) [@gerpux](https://www.ruby-forum.com/u/gerpux)\
**Post date:** [October 30, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/db4o-oo-database-for-ruby/118705/2 "2007-10-30T16:31:09Z")

</div>

Dear gerpux,

> I saw that the guys at db4o support ruby to some degree and I wanted  
> to know if anyone tried the db under ruby. Is this functional?[http://developer.db4o.com/ProjectSpaces/view.aspx/Tools\_And\_Add-Ons/L](http://developer.db4o.com/ProjectSpaces/view.aspx/Tools_And_Add-Ons/L)…  
> (project db4ro)  
> The issue has two sides:

1. I know that the db4o guys have ideas for a binding of the Java-db4o  
to Ruby.  
ButI have no knowledge how far this project has gone. Perhaps it’s  
easier even now with JRuby.  
If this is interesting for you (as the Java-Version is fast as hell  
and very mature)  
you might want to ask in the public db4o Forum about this.

2. The db4ro project on [rubyforge.org](http://rubyforge.org) is a research project. We didn’t  
have much time  
recently because we organize this object database conference  
[http://icoodb.org](http://icoodb.org).  
Nevertheless db4ro is a rewritten clone of db4o with the same basic  
API and some research more  
(but missing a 10000 db4o features). Just yesterday night it started  
being able to read simple  
objects and read them all (see Listing 1). You might check out he  
public code but I can not  
recommend this, as the current codebase is horrible, small and needs  
to be refactored massively.

Furthermore we have a smart research API that is not yet linked into  
the db4ro codebase  
but the query codebase is already mature and sometimes reminds you of  
AOQL being described  
in the paper cited here [http://odbms.org/about\_news\_20071015.html](http://odbms.org/about_news_20071015.html)  
See Listing 2. The query work has been done by Sten Friedrich and is  
still ongoing.

If you have any more questions, don’t hesitate to ask here or me  
directly  
edlich[at]gmail[dot]com

Stefan Edlich  
(Author of “The Definitive Guide to db4o” Apress Ic.)

Listing 1  
class Simpleexample  
def rundb4ro  
db = Db4ro.get\_object\_container (“C:/tmp/db4ro/db” +  
(rand\*10000).to\_i.to\_s)  
Db4ro.log.info(“Starting db4o example…”)  
t = db.getTransaction()  
t.start  
p1 = Person.new  
p1.name = “John”  
p1.age = 42  
db.set(p1)  
p1.name = “Susy”  
p1.age = 42  
db.set(p1)  
p1.name = “Ben”  
p1.age = 42  
db.set(p1)  
t.commit  
plist = db.get(Person.class)  
plist.each do |a\_person|  
Db4ro.log.info(“Objekt ausgelesen = #{a\_person.to\_s}”)  
end  
Db4ro.log.info(“Finishing db4o example!”)  
end  
end

Listing 2: (Query Beispiele)

customers\_list = customers.qwhere{|c| c.address.city==“London”}

objects\_list = customers.qselect{|c| [{:firstname =\> c.firstname},  
c.lastname, {:street =\> c.address.street.upcase},  
c.address.street.upcase]}

customers\_group = customers.qgroupby{|c| c}

min\_creditlimit = customers.qwhere{|c| c.address.city==“London”}.qmin{|  
c| c.creditlimit}

sum\_creditlimit = customers.qwhere{|c| c.address.city==“London”}.qsum{|  
c| c.creditlimit}

anonym\_objects\_list = customers.qjoin(orders){|c, o| [c, o.customer,  
{:name =\> c.firstname + " " + c.lastname, :orderdate =\>  
o.orderdate, :orderprice =\> o.price, :avgpriceforcustomer =\>  
c.orders.qavg{|o| o.price}}]}

unique\_prices = product\_unitprices.qunion(order\_prices).qorderby{|p|  
p}

and many more …

---

<div class="post-metadata">

**Author:** ![gerpux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/df788c/32.png) [@gerpux](https://www.ruby-forum.com/u/gerpux)\
**Post date:** [October 30, 2007, 6:23pm UTC](https://www.ruby-forum.com/t/db4o-oo-database-for-ruby/118705/3 "2007-10-30T18:23:42Z")

</div>

On Oct 30, 8:23 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> to be refactored massively.  
> I don’t recommend to create a separate rewrite, though. We currently  
> produce Java and .NET version with a converter called “Sharpen”. I  
> don’t know whetehr it would be possible to write a J2R converter, but  
> I would certainly recommend to investigate this path thoroughly if  
> there’s interest.

Please contact removed\_email\_address@domain.invalid if you’re interested to contribute to  
this project.

Christof  
db4objects, Inc.
