ruby - Import data from database_source.mdb to database_destination.mdb -


i have existing source mdb database , need programmatically import tables destination mdb.

the first approach import table per table and, iterating each row, copy record destination mdb database.

this has limitation because of amount of data copy, so, found db[:table_name].import method in ruby sequel, don't understand how works.

this code i'm using:

def import     @table_fields = {         :table_name = [:id, fiels_a, :field_b, :field_n]     }       @db_source = sequel.ado :conn_string => "provider=microsoft.jet.oledb.4.0;data source=source_db_file.mdb"      @db_destination = sequel.ado :conn_string => "provider=microsoft.jet.oledb.4.0;data source=destination_db_file.mdb"      begin         _copy_table :table_name     ensure         @db_source.disconnect         @db_destination.disconnect     end end  def _copy_table table_name     $logger.info "import table #{table_name}"     begin         @db_destination[table_name].truncate         # load data         data = @db_source[table_name].select(@table_fields[table_name])         # import data         @db_destination[table_name].import(@table_fields[table_name], data, :commit_every => 50)     rescue exception => e         $logger.error "failed import table #{table_name}, #{e.message}"     else         $logger.info "table #{table_name} imported."     end end 

i error:

ole error code:80040e14 in microsoft jet database engine syntax error (comma) in query expression 

i tried variants following:

# import data @db_destination[table_name].import(@table_fields[table_name], @db_source[table_name], :commit_every => 50) 

the result big different. no data exported, have no errors.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -