What’s the best way to do raw SQL in Ruby? Something like Perl’s DBI. I
see there is a Ruby
DBI but it seems in beta. Can one use ActiveRecord to run arbitrary
SQL statements? I’m not really interested in a full-fledged ORM - just
a way to run SQL succinctly and easily.
Hi
What's the best way to do raw SQL in Ruby? Something like Perl's DBI. I see there is a Ruby DBI <http://rubyforge.org/projects/ruby-dbi/> but it seems in beta. Can one use ActiveRecord to run arbitrary SQL statements? I'm not really interested in a full-fledged ORM - just a way to run SQL succinctly and easily.
Thanks
I think you'll find that Ruby's DBI works very well and you should give it a try, especially if you don't want the overhead of Rails. I've used it a couple of times and found it to be very easy having used Perl's DBI for many years. Feel free to post your script and any problems if you need further help.
On 12/24/07, Praveen Ray <praveen@perspectivepartners.com> wrote:
Hi
What's the best way to do raw SQL in Ruby? Something like Perl's DBI. I see
there is a Ruby DBI but it seems in beta. Can one use ActiveRecord to run
arbitrary SQL statements? I'm not really interested in a full-fledged ORM -
just a way to run SQL succinctly and easily.
I've also been using Ruby DBI for years without issue. I've written hundreds
of scripts using it and it's always worked a treat. I've used it with both
MySQL and SQL Server (though that was a long time ago).
Joey
···
On Dec 24, 2007 3:17 PM, Michael Glaesemann <grzm@seespotcode.net> wrote:
On Dec 24, 2007, at 9:35 , Praveen Ray wrote:
> What's the best way to do raw SQL in Ruby? Something like Perl's
> DBI. I see there is a Ruby DBI but it seems in beta.
I've been happily using Ruby DBI as is. Of course, test it to make
sure it suits your needs, but I doubt you'll have many problems with it.
I've also been using Ruby DBI for years without issue. I've written hundreds
of scripts using it and it's always worked a treat. I've used it with both
MySQL and SQL Server (though that was a long time ago).
If you using SQL server don't rely on prepare statements to protect
you from SQL injection attacks. All it's doing is simple string
substitutions (it doesn't actually create prepared statements).
I had better luck with ODBC then ADO when going against SQL server
FTIW. The ADO driver need some more work.