Import

Import scripts are used for uploading spatial files into spatially enabled database. It needs at the least one file to import the data.

  • *.script – THIS FILE IS MANDATORY and in the single file scenario it contains all information about a source and destination for data import,
  • *.source – contains common information about all sources of the data listed in the script file,
  • *.destination – contains common information about the destination of the import job (this is usually the Main Repository connection string from Earthlight web.config file without the table name entry)

All of these files must have the same names to be treated by Data Pump as a single script – e.g. my_import.script, my_import.source, my_import.destination.

Single file scenario

You can include all necessary information about the source and the destination of import in the .script file, in which case there is no need to create .source or .destination files. An example of a self contained my_import.script file can be found below:

1
2
3
4
5
6
7
8
9
<?xml version="1.0"?>
<Script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Actions>
    <Action xsi:type="Load">
      <Source>d:\SDrive\OS Code Point.csv</Source>
      <Destination>database=statmap;user id=USER;password=PASSWORD;timeout=15;pooling=True;enlist=False;integrated security=False;initial catalog=EarthlightDB;data source=dbserver\sqlexpress;table name=Code_Point;cartridge=SqlServer;schema=dbo</Destination>
    </Action>
  </Actions>
</Script>
Please note that table name entry in <Destination> section is specific to the dataset being imported.

As you can see both <Source> and <Destination> provide complete location details. In some cases however you may want to use the additional files.

Two files scenario

Imagine a situation where more than one file is imported via single script to the same database. In this case it is advisable to use .destination file where the connection string is provided and place the name of the table in the <Destination> tag in the .script file. Data Pump will read content of the .destination file and add it to the <Destination> from the .script file to create the full location details.

An example of this approach is shown below:

  • my_import.script file
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    <?xml version="1.0"?>
    <Script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Actions>
        <Action xsi:type="Load">
          <Source>d:\Tables To Upload\TABLE_1.tab</Source>
          <Destination>TABLE_A</Destination>
        </Action>
        <Action xsi:type="Load">
          <Source>d:\Tables To Upload\TABLE_2.shp</Source>
          <Destination>TABLE_B</Destination>
        </Action>
        <Action xsi:type="Load">
          <Source>d:\Tables To Upload\TABLE_3.mid</Source>
          <Destination>TABLE_C</Destination>
        </Action>
      </Actions>
    </Script>
  • my_import.destination file
    1
    database=statmap;user id=USER;password=PASSWORD;timeout=15;pooling=True;enlist=False;integrated security=False;initial catalog=EarthlightDB;data source=dbserver\sqlexpress;cartridge=SqlServer;schema=dbo
Please note that there is no table name in the .destination file.

Three files scenario

To expand even further on this let’s see an example of an import script where all three files are separated. This scenario is virtually never used for import, since it requires all files to be of the same format and located in a single location. As you can see in my_import.source file:

  • the data source points to a single folder
  • the cartridge declares all files to be ESRI Shapefiles

In this scenario, the my_import.script file contains the names of the files without extension in <Source> tags and the names of the database tables in the <Destination> tags

The example below is more of a proof of concept than an actual, useful script.

  • my_import.script file
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    <?xml version="1.0"?>
    <Script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Actions>
        <Action xsi:type="Load">
          <Source>TABLE_1</Source>
          <Destination>TABLE_A</Destination>
        </Action>
        <Action xsi:type="Load">
          <Source>TABLE_2</Source>
          <Destination>TABLE_B</Destination>
        </Action>
        <Action xsi:type="Load">
          <Source>TABLE_3</Source>
          <Destination>TABLE_C</Destination>
        </Action>
      </Actions>
    </Script>
  • my_import.source file
    1
    data source="d:\Tables To Upload\";cartridge=ESRI Shapefile
  • my_import.destination file
    1
    database=statmap;user id=USER;password=PASSWORD;timeout=15;pooling=True;enlist=False;integrated security=False;initial catalog=EarthlightDB;data source=dbserver\sqlexpress;cartridge=SqlServer;schema=dbo
Please note that there is no table name in the .destination file.