import
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_urlThe 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_tokenThis 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(
api_base_url,
api_access_token,
url,
connection,
destination,
autoguessing
)Description
Imports a file that is available at a defined URL into a table in the current connection.
api_base_url:STRING|NULLURL of the API where the customer account is stored. If default credentials have been configured withSETUPNULL can be passed to use them.api_access_token:STRING|NULLan API Access Token that is allowed to use the Import API. If default credentials have been configured withSETUPNULL can be passed to use them.url:STRINGthe URL where the file to import can be found.connection:STRINGthe name of the connection to use.destination:STRINGname of the table to create.options:STRINGA JSON string with additional options. The following are the options currently supported:autoguessing:BOOLEANtrue if the Import API should guess the column types. If false, all columns will be of typeSTRING.
Examples
CALL `carto-un`.carto.IMPORT_URL(
'my_api_base_url',
'my_api_access_token',
'http://my.data.url.com/mytable.geojson',
'myconnection',
'myproject.mydataset.mytable',
'{"autoguessing": true}'
);
-- The table `myproject.mydataset.mytable` will be createdCALL `carto-un-eu`.carto.IMPORT_URL(
'my_api_base_url',
'my_api_access_token',
'http://my.data.url.com/mytable.geojson',
'myconnection',
'myproject.mydataset.mytable',
'{"autoguessing": true}'
);
-- The table `myproject.mydataset.mytable` will be createdCALL carto.IMPORT_URL(
'my_api_base_url',
'my_api_access_token',
'http://my.data.url.com/mytable.geojson',
'myconnection',
'myproject.mydataset.mytable',
'{"autoguessing": true}'
);
-- The table `myproject.mydataset.mytable` will be created
This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 960401.
Last updated
Was this helpful?
