Class: BradyW::BCP
- Includes:
- WindowsPaths
- Defined in:
- lib/bcp.rb
Overview
Supports using Microsoft BCP to load CSV data. Unlike BCP out of the box, this task attempts to “support” comma escaping by converting your CSV files to files with an odd delimiter before loading them in with BCP.
Instance Attribute Summary collapse
-
#delimiter ⇒ Object
writeonly
Optional If the delimiter exists in your code (the task will fail if it does), you need to change this attribute.
-
#files ⇒ Object
Required Supply the files you wish to load into your tables here.
-
#identity_inserts ⇒ Object
writeonly
Optional If this is set to true, then BCP’s “-E” command line argument will be used.
-
#version ⇒ Object
Optional By default, this looks for your installed version of BCP with SQL Server 2008.
Attributes inherited from BaseTask
Instance Attribute Details
#delimiter=(value) ⇒ Object
Optional If the delimiter exists in your code (the task will fail if it does), you need to change this attribute.
16 17 18 |
# File 'lib/bcp.rb', line 16 def delimiter=(value) @delimiter = value end |
#files ⇒ Object
Required Supply the files you wish to load into your tables here. They should be named
using the following pattern SEQUENCE-TABLENAME.csv
Example:
01-users.csv
02-accounts.csv
OR
001-users.csv
002-accounts.csv
28 29 30 |
# File 'lib/bcp.rb', line 28 def files @files end |
#identity_inserts=(value) ⇒ Object
Optional If this is set to true, then BCP’s “-E” command line argument will be used. If you have primary keys in your files you wish to preserve, set this to true. Default is false.
36 37 38 |
# File 'lib/bcp.rb', line 36 def identity_inserts=(value) @identity_inserts = value end |
#version ⇒ Object
Optional By default, this looks for your installed version of BCP with SQL Server 2008.
If you're using SQL Server 2005, set this to "90"
32 33 34 |
# File 'lib/bcp.rb', line 32 def version @version end |