# Source code for the SQLServerAdapter extensions. module ActiveRecord #:nodoc: module ConnectionAdapters #:nodoc: # Adds new functionality to ActiveRecord SQLServerAdapter. class SQLServerAdapter < AbstractAdapter protected # Call +bulk_load+, as that method wraps this method. # # Bulk load the data in the specified file. This implementation relies # on bcp being in your PATH. # # Options: # * :ignore -- Ignore the specified number of lines from the source file # * :columns -- Array of column names defining the source file column order # * :fields -- Hash of options for fields: # * :delimited_by -- The field delimiter # * :enclosed_by -- The field enclosure def do_bulk_load(file, table_name, options={}) env_name = attrs[:env] || RAILS_ENV config = ActiveRecord::Base.configurations[env_name] puts "Loading table \"#{table_name}\" from file \"#{filename}\"" cmd = "bcp \"#{config['database']}.dbo.#{table_name}\" in " + "\"#{filename}\" -S \"#{config['host']}\" -c " + "-t \"#{options[:delimited_by]}\" -b10000 -a8192 -q -E -U \"#{config['username']}\" " + "-P \"#{config['password']}\" -e \"#{filename}.in.errors\"" `#{cmd}` end end end end