• Dimitri Miller
        Has successfully completed the online course Basics (100)
      2 years ago #30305

      Hi everyone,

      I’m trying to import Data from a .txt file from an URL. (Please notice, that the URL has around 260 Mbyte, a shorter File is attached) https://files.admin.ch/astra_ffr/mofis/Datenlieferungs-Kunden/opendata/2000-Typengenehmigungen_TG_TARGA/2200-Basisdaten_TG_ab_1995/TG-Automobil.txt

      My idea was to donwload the file from URL, and afterwards use a SQL statement. like
      LOAD DATA INFILE ‘/tmp/mydata.txt’ INTO TABLE table_name;

       

      My question are:

      1. How can I download the file to my Simplifier application, without
      2. What is the path to the file after downloading it?

      Best regards
      Dimitri

       

       

      Attachments:
      You must be logged in to view attached files.
      Armin Winkler
          Has successfully completed the online course Introduction
          Has successfully completed the online course Intermediate (200)
          Has successfully completed the online course Advanced (300)
          Has successfully completed the online course Basics (100)
        2 years ago #30388
        Up
        0
        Down
        ::

        Hi Dimitri,

         

        the approach you propose to populate a table in your SQL data base is considered to be potentially unsafe and abusable, since the user that is executing the statement needs to have File privileges granted to them on the server. The official MySQL documentation itself warns to grant such privileges and execute said LOAD DATA statement, cf. https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html.

         

        I would recommend you to implement your own import function in a Simplifier application using Javascript functionality. Here are the basic steps you need to take in your app workflow:

         

        1. Use a sap.ui.unified.FileUploader widget to get access to your local .txt file

        2. Read in the file as a text with the help of a FileReader

        3. Pass the text as input to the client-side business object ITIZ_CSV and its function CSV_to_JSON which is part of our Standard Content

        4. Use a repeatable statement SQL connector call which is invoked from a server-side business object function to pass the whole JSON array and insert it into your data base table

         

        Kind regards,

         

        Armin

         

      Viewing 2 posts - 1 through 2 (of 2 total)

      You must be logged in to reply to this topic.