Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Excited n00b

Reply
Thread Tools

Excited n00b

 
 
Mark Carter
Guest
Posts: n/a
 
      02-15-2005
I jobby out VBA code for a living, although I use python wherever I can.
I thought I'd try out Ruby to see what all the fuss was about.

So far, I'm impressed. Here's a little proggy that I knocked out to dump
the table structure of a database:

require 'win32ole'

def schema()
@MDB_FILE_NAME = "C:\\mcarter\\srel\\2292-Stargate\\demo.mdb"

# Create the object
conn=WIN32OLE.new("ADODB.Connection")
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=\"#{@MDB_FILE_NAME}\""
conn.open


#http://msdn.microsoft.com/library/de...openschema.asp

#http://msdn.microsoft.com/library/de...schemaenum.asp
adSchemaTables = 20 #constant
rs = conn.OpenSchema(adSchemaTables)
rs.MoveFirst if !rs.eof
while !rs.eof
yield rs
rs.MoveNext
end
rs.close()
conn.close
end

schema { | table |
puts "NEW TABLE"
for field in table.Fields
puts "%-15s %10s" % [field.name, field.value]
end
puts
}



OK, it could do with some refactoring, but I was just trying to get
something working. I think that impresses me about this block stuff is
that it's a really neat way to hide messy implementation details. ADODB
has a slightly strange way of iterating over records (the !rs.eof bit);
but that doesn't matter because it's all hidden away. I just iterate
over the recordset like it was a normal list.

I'm tempted to stick around to see what other goodies Ruby has in store.

What I'm actually trying to do is read a database, bump the date values
of some of the fields, create some new records, and put the result into
a new database. Before I completely re-invent the wheel, is there a ruby
library that is likely to be of assistance?
 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      02-15-2005

"Mark Carter" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> I jobby out VBA code for a living, although I use python wherever I can.
> I thought I'd try out Ruby to see what all the fuss was about.


Welcome aboard!

> So far, I'm impressed. Here's a little proggy that I knocked out to dump
> the table structure of a database:
>

<snip/>

> OK, it could do with some refactoring, but I was just trying to get
> something working. I think that impresses me about this block stuff is
> that it's a really neat way to hide messy implementation details. ADODB
> has a slightly strange way of iterating over records (the !rs.eof bit);
> but that doesn't matter because it's all hidden away. I just iterate
> over the recordset like it was a normal list.
>
> I'm tempted to stick around to see what other goodies Ruby has in store.


I'm nearly sure you'll stay longer...

> What I'm actually trying to do is read a database, bump the date values
> of some of the fields, create some new records, and put the result into
> a new database. Before I completely re-invent the wheel, is there a ruby
> library that is likely to be of assistance?


Look at the Ruby DBI/DBD implementations. It typically comes preinstalled
but if you need more, you can look in the RAA http://raa.ruby-lang.org/

There's also other DB handling stuff:
http://raa.ruby-lang.org/cat.rhtml?c...minor=Database

Kind regards

robert

 
Reply With Quote
 
 
 
 
Gavri Fernandez
Guest
Posts: n/a
 
      02-16-2005
On Tue, 15 Feb 2005 21:54:53 +0900, Mark Carter <(E-Mail Removed)> wrote:
> What I'm actually trying to do is read a database, bump the date values
> of some of the fields, create some new records, and put the result into
> a new database. Before I completely re-invent the wheel, is there a ruby
> library that is likely to be of assistance?


Check out Active Record (http://ar.rubyonrails.org)

--
Gavri
---------------------------------------------------
I blog here: http://gavri.blogspot.com


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
i'm excited luckydig1t Case Modding 10 04-06-2010 05:06 AM
D3000 and D300s is coming... so excited... TK Digital Photography 1 07-27-2009 09:33 AM
Excited New Games amcbryde@cfl.rr.com Digital Photography 0 01-16-2006 04:42 AM
Excited Alan D-W Digital Photography 5 11-28-2003 02:02 PM
WHICH Printer? Not excited about the Epson 7500 Sbtypesetter Digital Photography 3 09-12-2003 07:06 AM



Advertisments