Automação da Atualização dos dados

From TaticView
Revision as of 17:29, 18 October 2016 by Luiz (talk | contribs) (Created page with " '''Sintaxe de solicitação: tvcli -cmd get_token_by_password -user <usuário> -password <senha> [-token_name "<nome do token>"]'''")
Jump to: navigation, search

Automação de importações de dados no TaticView

Você pode através dess processo automatizar importações dos seus Arquivos de Dados.

Para automatizar as importações no TaticView são necessário alguns procedimentos de configuração e uso do programa de linha de comando TVcli.

Caso tenha dificuldades abra um ticket de suporte em https://support.taticview.com/open.php/?&lang=pt_br. Teremos prazer em lhe ajudar.

Instalando o TVcli

Primeiramente baixe o instalador:

  • Windows
  • Linux
  • Mac-OS

Depois execute a instalação na mesma máquina onde estarão os arquivos que serão importados automaticamente.


Geração do TOKEN DE ACESSO

É necessário possuir um TOKEN DE ACESSO cadastrado no TaticView e no TVcli antes de poder executar uma automação de importação. Um TOKEN DE ACESSO está sempre associado a um usuário TaticView. O TOKEN DE ACESSO é como uma senha gerada pelo TaticView que permite acesso a sua conta pelo TVCli, ele pode ser revogado por você a qualquer momento, permitindo assim que você decida quem pode acessar sua conta no TaticView e quando.

É possível gerar o TOKEN DE ACESSO de duas maneiras:


Pelo TVcli

  1. Executar o comando via linha de comando pedindo geração de um novo TOKEN DE ACESSO
   Sintaxe de solicitação: tvcli -cmd get_token_by_password -user <usuário> -password <senha> [-token_name "<nome do token>"]
 -cmd                   - get_token_by_password - Requests and stores the ACCESS TOKEN through command line. (TVcli)
 -user                  - TaticView user
 -password              - TaticView password
 -token_name (optional) - The name that you want to give to the access token. Default name "TaticView CLI"          
 Example: tvcli -cmd get_token_by_password -user myemail@email.com -password 123466 -token_name "TVcli Server 1"


Through TacticView interface

  1. Identify yourself on TaticView and access the My account button ACCESS TOKENS;
  2. On !identificacao-novo-token.png! enter a name to identify the ACCESS TOKEN on the list and then click on Generate new TOKEN.
  3. An ACCESS TOKEN will be generated !generated-token.png!
  4. Run TVcli informing the generated ACCESS TOKEN
 Syntax: tvcli -cmd store_token -user <user name> -token <generated token>
 -cmd   - store_token - stores token generated through the interface
 -user  - TaticView user 
 -token - The token generated through the interface
 Example: tvcli -cmd store_token -user meuemail@email.com -token 9bdr845gh5r4r1vd5d5


Importing in an automated way

You can only automate the import of data files that have been already created on TaticView, so you are going to need at least one manual import to create the necessary structure. Then you must grant the automatic import to the desired data file.. To do this click on the imported file (On the TaticView interface), select Properties, and check the checkbox Automatic Importation, which displays the identifier code of your data file, as you can see in the example below:

!datamart-dropdown.png!


!automatic-importation.png!.

Once the data file is imported, granted for automatic import and you have your identification code, you can run the import through the command line.

 Syntax: tvcli -cmd import_file -user <user name> -datamart <identifier> -file "<file/spreadsheet>" [-type <type>] [-wait] [-noerror] -[notifyshare]
 -cmd                   - import_file   - uploads the data file and places it in the import queue
 -user                  - TaticView user 
 -datamart              - identifier of the data file obtained in the Data file properties at the interface.
 -file                  - Text data file (CSV) or spreadsheet (XLSX,XLS) to be imported.
 -type (opcional)       - clear_and_add - Deletes all data from TaticView Data File and imports the new data. (default)
                          append        - Adds the new data at the end of the TaticView Data File. It is necessary to be careful not to duplicate any data.
 -wait (opcional)       - waits for the end of the import.  It is needed to test Output Status
 -noerror (opcional)    - does not notify the user if an error occurs during the process
 -notifyshare (opcinal) - sends data update notification to users who have these data file dashboards shared when the importing process ends without errors.
 Example:
 tvcli -cmd import_file -user myemail@email.com -datamart 246 -file "c:\taticview\imp\spreadsheet.xlsx"
 tvcli -cmd import_file -user myemail@email.com -datamart 246 -file "c:\taticview\imp\file.csv" -notifyshare
 tvcli -cmd import_file -user myemail@email.com -datamart 246 -file "c:\taticview\imp\spreadsheet.xlsx" -wait
 tvcli -cmd import_file -user myemail@email.com -datamart 246 -file "c:\taticview\imp\spreadsheet.xlsx" -type clear_and_add
 tvcli -cmd import_file -user myemail@email.com -datamart 246 -file "c:\taticview\imp\spreadsheet.xlsx" -type append
 tvcli -cmd import_file -user myemail@email.com -datamart 246 -file "c:\taticview\imp\spreadsheet.xlsx" -type append -noerror


Command return test

The TVCI executable returns different codes to report the success or failure during the execution process.

 0 - Success
 8 - Error

A notification is sent to the user if an error occurs during the import process. A log with the imports details is generated in the logs directory, below the directory where TVcli was installed.

An example of Windows running script:

 tvcli -cmd import_file -user meuemail@email.com -datamart 246 -file "c:\taticview\imp\planilha.xlsx" -notifyshare
 if errorlevel <> 0
   Error notification by email
 fi


Important

The free version grants you automation import from only one data source. You need to configure the feature "*automatic data update*" in your subscription to automate the imports of more data sources.