Personally I'm spoiled to ORMs.  My current favorite is DataMapper
(warts and all).  To install:

gem install dm-core dm-more data_objects do_sqlite3

then you can code like:

require 'rubygems'
require 'dm-core'

# in memory SQLite3 database
DataMapper.setup :default, 'sqlite3::memory:'

class Address
  include DataMapper::Resource
  property :id, Serial
  property :street, String, :length => 100
  property :city, :length => 100
  property: state, :length => 3

  has 0..n, :people, :through => Resource
end

class Person
  include DataMapper::Resource
  property :id, Serial
  property name, Text

  has 0..n, :addresses, :through => Resource
end

DataMapper.auto_migrate!

Now you easily access the data:

# print everyone with an address in Texas
Address.all(:state => 'TX').each do |addr|
  addr.people.each do |person|
    puts person.name
  end
end

Much better IMO than SQL...

Most of the current warts are with the relationships, but the next
branch includes a complete rewrite to address the relationship
problems.  This will be version 0.10.0 and should be released
real soon now (tm).  :)

HTH,
Roy

On Jun 7, 2009, at 6:14 AM, dave wrote:

Thanks Satoshi :)

one answered one to go...

On Sunday 07 June 2009 11:00:17 pm Satoshi Asakawa wrote:
> Hi Dave,
>
> > where can one go for a searchable index of this
> > forums messages?
>
> http://www.mail-archive.com/[email protected]/
>
> Hope it helps. :)
> ashbb
>
> On Sun, Jun 7, 2009 at 7:51 PM, dave <[email protected]> wrote:
> > Hi folks,
> >
> >
> > been to this site http://sqlite-ruby.rubyforge.org/sqlite3/faq.html and
> > printed off the hints there.
> >
> >
> > but looking for more... and coming up empty.
> >
> >
> > I like to be able to get the DB and shoes frontend talking and playing > > nice within two weeks (no data validation as I want a prototype 1st).
> >
> >
> > can someone point me to some other sites (that are ruby not RoR centric)?
> >
> >
> > search google on various searches like ruby with sqlite3 but mostly it's
> > all RoR.
> >
> >
> > also any pointer on bindings (if no one can point me to a website)?
> >
> >
> > like to know more clearly how to inject (if that the word) a string
> > dynamically into a SQL select satement
> >
> >
> > e.g. from the FAQ (think the call it placeholders in an sql statement.
> >
> >
> > Have had some exposure to RDBMS's in the past but that was some time ago
> > and ruby /shoes are still newish to me.
> >
> >
> > what i like to be able to do is something like the #{rubyvar} within a > > puts statement where value within rubyvar is displayed but have this
> > inside a select statement.
> >
> >
> > Oh can you do this?
> > stmt = "select * from A_table where table_column = " + rubyvar
> >
> >
> > db.prepare(stmt)
> >
> >
> > how much harder would active records be to the DBI interface to get up
> > and running with?
> >
> >
> > and any web sites that I could go to for code samples etc relating to
> > sqlite3?
> >
> >
> > also lastly and this is off topic - sorry but where can one go for a
> > searchable index of this forums messages?
> >
> >
> > rgds,
> >
> >
> > dave.




Reply via email to