views:

421

answers:

2

I see that the IronRuby team has documented using ActiveRecord in IronRuby with MSSQL - they indicate that some adjustments were required to the adapter.

In interview on 8/11/2009, Jimmy indicates a major drawback of IronRuby:

The main limitation is that IronRuby does not support any of the C-based Ruby libraries

That indicates that the SQLite-Ruby library that depends on sqlite.dll is probably out of the question. However, in the same interview, he says:

For the database you can use SQLServer Express (which is free), or any .NET based database, like the recent csharp-sqlite port.

That sounds promising, but I'm a bit overwhelmed on how to begin! How do I go about connecting Ruby's ActiveRecord to csharp-sqlite or where can I look for more guidance?

I found some more write-up on IronRuby and SQLite, but I may need some translation help?

The current solution is to port do_sqlite3 to use all .NET APIs. There are a couple ports of SQLite to .NET, but none are widely used yet. For 1.0 we will have an ironruby-dbi gem for using .NET based databases through the Ruby DBI API; so using SQLExpress and SQLServer will work with an appropriate sqlserver adapter. I'm not sure if there is a do_sqlserver adapter yet for DataMapper, but we'll leave that to the community for doing.

Does this imply that my technology stack could go something like: ActiveRecord uses SQLiteRuby, SQLiteRuby is tweaked to use ironruby-dbi (should be little change since this is the Ruby DBI API??) then ironruby-dbi has the smarts to work with a .NET based database such as c#sqlite. Of course I will need an adaptor to go between ActiveRecord and SQLiteRuby ... hopefully no change required there?

Sugggestions, Advice, Tips?

A: 

Have you tried using the SQLite adapter? It might work out-of-the-box.

I haven't tried it personally though.

Shay Friedman
And what do I do about linking to the lower level ruby Sqlite gems that the out-of-the-box SQLite adapater relies? Thx.
jrhicks
If they are not working in IronRuby, someone will have to port the SQLite ActiveRecord adapter. This should be very easy since SQLite has a .Net library which is very similar to the SQL Server library (and it works great in IronRuby, I've tried it).In short, if the SQLite gems are not working on IR, using SQLite in IronRuby on Rails will take some more work :)
Shay Friedman
What is the SQLite .Net library that is similar to the SQL Server library that you have used?
jrhicks
I used System.Data.SQLite. You can find it at http://sqlite.phxsoftware.com/
Shay Friedman
Looks like SQLite3/Ruby has been ported to IronRuby: http://github.com/jwthompson2/sqlite3-ironruby
Nathan
+1  A: 

you won't be able to use activerecord as is.

You can either wrap the ADO.NET provider for SQLite or you can perhaps help with the ironruby-dbi project and provide a dbi adapter that handles sqlite correctly. From then on adding it to rails is easy as it would require replacing the connection with the dbi connection.

It is a work in progress though and at this moment most efforts have been around sql server, but I too would like to get sqlite working properly on IronRuby with rails.

Another approach would be to change the active record adapter for sqlite to work with the ADO.NET provider (that would probably require the least effort but won't help outside the rails community). I have a pretty good idea of what needs to happen to make it all work but I simply don't have the time to do all of these things, unfortunately.

Casual Jim
I like the 3rd option since I'm only interested in IronRuby for desktop application development. There is a lot of fuss in the Ruby Community about a good GUI framework and I think IronRuby is decent answer to that problem ... but I'm just not feeling the love from the .NET method of ORM. Do you think I should learn an .NET based ORM? Thx.
jrhicks
I've found .NET OR/M's to be awkward with ironruby. The reason is that they have to make heavy use of generics etc to do a decent job which takes a lot of niceness from the ruby language. My favourite option is to get sqlite working with ironruby is to integrate it in ironruby-dbi. From then on you can use one of the ruby or/m's with little or no effort. I can help you if you're stuck if you're up for option 2 or 3, otherwise you'll have to be patient till somebody else gets round to it.
Casual Jim