I am using Ruby on Rails and I have to create an importer from one database to another. There are over 100 tables in each database and I don't want to create a model for each table. Is there any possibility to create queries, specifying a table name? I don't want a model bind to a table.
For example: FirstDatabase.select('*').from('some_table').where(...)
Without set_table_name ...
just dynamic models
Also I need to do inserts in different tables
I would not use models for that task at all. Instead, use the #select_all, #exec_insert, #exec_update, and #exec_delete methods of the base connection as appropriate.
Returns an array of hashes for rows.
Inserts a row. The values will need to be properly escaped strings, dates, etc. for whatever database you are using.
Returns a quoted string representation suitable for use in a SQL statement.
Returns a quoted date/time representation in UTC timezone.
To deal with the multiple databases, you can do something like set up a single model for each, and then get connections from those models instead of from ActiveRecord::Base.