"Database examples"

Sean
Sean New Altair Community Member
edited November 5 in Community Q&A
Hi There,

I would like to iterate through rows in an SQL table, process each row and insert the results into a new row in a different table.

I have not been able to find good examples for playing with a database like this, any suggestions?

Regards,
Sean.

Answers

  • MariusHelf
    MariusHelf New Altair Community Member
    Hi,

    what do you have so far? Did you already manage to setup the connection to the SQL server? Then the next step will be to play around with the Read Database operator. If your data is fits into memory, the easiest way will be to download it with the aforementioned operator, transform it, e.g. with Generate Attributes if that fits your needs, and then write it back into the database with Write Database. Please note the different options on how to deal with existing tables in that operator.

    I think if you experiment or half an hour with these operators on a sample database (don't use your production database for experiments!), you should be fine.

    Happy Mining!
    ~Marius
  • Sean
    Sean New Altair Community Member
    Hi Marius,

    Thanks for the feedback. I have been able to read a row from a table from a database and clean the data. How to automatically write that data back to the database is still a mystery to me. I am also unsure how to implement loops or a way of iterating through a number of rows.

    If I can do this it will be great as I really like Rapidminer and would prefer to use it moving forward if possible.

    Any suggestions would be appreciated.

    Regards,
    Sean.
  • MariusHelf
    MariusHelf New Altair Community Member
    Well, with the Write Database operator you can easily write the data back. As with the Read Database operator, you have to define the connection on top. Then you select the table which you want to write. The overwrite mode specifies how to deal with existing tables: "overwrite" creates a new table each time the operator is executed, "overwrite first, then append" creates a new table on first execution, and on additional calls (e.g. in a loop) the rows are appended, and "append" simply appends the lines to the end of the database table.

    The input of the operator is an example set, whose rows will be written to the database in the way explained above.

    Regards,
    Marius