Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

...

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>

 

 

Info

Please note that table name entry in <Destination> section is specific to the dataset being imported.

 

...

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

     

     

     

...

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

     

     

...