Keith Devens .com |
Saturday, July 5, 2008 | ![]() |
| "It's no trick for talented people to be interesting, but it's a gift to be interested. We want... – Randy S. Nelson (dean of Pixar University) | ||
|
| ← Sequel: Lightweight ORM library for Ruby | WoW Forums -> Feral PvP is fine, L2P... → |

Revence (http://freeshells.ch/~revence) wrote:
Keith (http://keithdevens.com/) wrote:
ADODB is for PHP :-P
just provide the conn string and you're rolling.
Same for Ruby's DBI. I'll post the code later. Super easy.
Keith (http://keithdevens.com/) wrote:
Here's a modified snippit of some code I wrote recently. Like I said, super easy:
require 'dbi'
connstr = "DBI:ADO:Provider=SQLOLEDB;Data Source=IP_ADDRESS;"+
"Initial Catalog=YOURDB;Persist Security Info=True;"+
"User ID=USER;Password=PASS"
DBI.connect(connstr) do |db|
db.select_all("SELECT * FROM Tasks WHERE Enabled = 1") do |row|
name = row["Name"].gsub(/[^\w]/,"_") # replace invalid characters
File.open("./data/#{name}.txt", 'w') do |file|
puts "Writing command to file #{name}"
file.write(row["Command"])
end
end
end
(Had to word wrap some to make it fit.) Note that Ruby's do ... end blocks ensure proper resource closure.
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):
Generated in about 0.117s.
(Used 8 db queries)

I use ADODB when on Windows (for 'tis fast and tried and true). And it goes for my PostgreSQL and Access and MS SQL Server ... just provide the conn string and you're rolling.