Multiple database connections from Rails

18 views
Skip to first unread message

Michael Prasuhn

unread,
May 14, 2013, 10:59:01 PM5/14/13
to pdxruby-...@googlegroups.com
Got to Hack+Help a little late tonight and didn't get a change to introduce myself and the question/problem I'm working on.

I'm working on porting an ancient PHP app to Rails and one of the requirements is that it fetches data from a remote MSSQL server to populate the local DB since the remote server isn't "webscale." I'm not sure what the best approach to this problem is but from what I've heard, I'm leaning towards using ActiveRecord as normal with Rails and adding Datamapper models to represent the legacy data in MSSQL since this seems to be something that Datamapper is good at (http://datamapper.org/docs/legacy.html). Is this a sane idea or should I stick to just one ORM for this project?

I don't have any control over the MSSQL schema, so I'm a little nervous to try to bend ActiveRecord to work with it.

Also, I was wondering if there was anyone that could walk me through getting started with JRuby since apparently the sqlserver adapter for Datamapper doesn't work with MRI. Alternatively I've tried connecting to SQL Server with DBI and ODBC, but that seems to be causing seg faults, and I have no idea where to start with trying to fix that. I've included a copy of the error with DBI here: http://pastie.org/7909578.

So if anyone has any other ideas about how I could get Rails talking to MSSQL, while also talking to Postgres/MySQL, I'd love to hear your suggestions.

Thanks

-Mike


Michael Kaiser-Nyman

unread,
May 15, 2013, 2:20:22 AM5/15/13
to pdxruby-...@googlegroups.com
Hey Mike - you and I chatted about this tonight after you sent this
message, and I suggested that, at least to begin with, you stick to
just the MSSQL server and co-locate your web server with it. I didn't
think about the issues with Active Record naming conventions, but I
just wanted to throw out there that I've run across a little bit of
Active Record's flexibility with names - I once worked with a database
that had capital letters in the column names, and it turns out you can
just use capital letters in the method and symbol names (e.g.,
Record.Column, or Record.where(:Column => 'foo'), or
validates_presence_of :Column). You may run into other problems, but
at least this won't be one of them. Good luck!
> --
> You received this message because you are subscribed to the Google Groups "pdxruby-beginners" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pdxruby-beginn...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
Reply all
Reply to author
Forward
0 new messages