import

ADVANCED

This module contains procedures to import tables for a given URL containing a file in any of the formats supported by the CARTO Import API.

For manual installations of the CARTO Analytics Toolbox, after installing it for the first time, and before using any of the module functions, you need to call the SETUP procedure to configure the import and gateway functions. It also optionally sets default credentials.

Credentials

Two parameters are needed:

  • api_base_url The API base URL is simply the address through which you can access all the services of your CARTO account, and it depends on the region or premises where your account is located. Usually it will be this one: https://gcp-us-east1.api.carto.com.

  • api_access_token This token is an API Access Token that is allowed to use the Import API. You must keep this secret! Anyone that has access to this token can use up the import functionality assigned to your account.

Both the API base URL and your API access token can be accessed through the developers section of the CARTO user interface. The API base URL is displayed inside this section while for the API access token you will have to create a new API access token allowing the Import API.

For more information about CARTO for developers, please check our documentation for Developers.

If default credentials are provided to the SETUP procedure, you can pass NULL values for the credentials in the import functions, and the credentials configured during SETUP will be used.

IMPORT_URL

IMPORT_URL(
  url,
  connection,
  destination,
  autoguessing,
  api_base_url,
  api_access_token)

Description

Imports a file that is available at a defined URL into a table in the current connection.

  • url: STRING the URL where the file to import can be found.

  • connection: VARCHAR(MAX) the name of the connection to use.

  • destination: VARCHAR(MAX) name of the table to create.

  • options: VARCHAR(MAX) A JSON string with additional options. The following are the options currently supported:

    • autoguessing: BOOLEAN true if the Import API should guess the column types. If false, all columns will be of type STRING.

  • api_base_url: VARCHAR(MAX)|NULL URL of the API where the customer account is stored. If default credentials have been configured with SETUP NULL can be passed to use them.

  • api_access_token: VARCHAR(MAX)|NULL an API Access Token that is allowed to use the Import. If default credentials have been configured with SETUP NULL can be passed to use them.

Examples

CALL carto.IMPORT_URL(
    'http://my.data.url.com/mytable.geojson',
    'myconnection',
    'myproject.mydataset.mytable',
    '{"autoguessing": true}',
    'my_api_base_url',
    'my_api_access_token'
);
-- The table `myproject.mydataset.mytable` will be created

Last updated