mysql database writer,create UUID

hello everyone
I want to add data into an exsiting table in mysql database.But the table has an item “UUID”.
So how can I create the UUID in KNIME?
Thank you!

Hi @vzzw

Although I don’t believe KNIME has a node to generate UUIDs for you automatically, there are several other ways you might do it:

  • package UUID() in R using the R Snippet node
  • import uuid in Python using the Python Snippet node
  • online tools (https://www.uuidgenerator.net/) that create files you could then import

Then it’s just a matter of combining the UUID with the rest of your dataset.

thank you four your help!
I 'm not good at R or Python,could you show me some clear details,please?

Sure, here’s a workflow that uses an R Snippet.

2019-04-23%2010_48_07-KNIME%20Analytics%20Platform

2019-04-23%2010_48_15-Data%20Output%20-%203_2%20-%20R%20Snippet%20(Generate%201%20UUID)

GenerateUUIDExample2.knwf (11.5 KB)

3 Likes

That’s great.It worked! I have installed python3.7 and found some code,such as:
import uuid
print uuid.uuid1()
But it dosn’t work. So how to do it with"python snippet"? I’m a beginner and very interested in it,thanks again :slight_smile:

Here’s an updated workflow that should work, assuming your Python environment is setup to work with KNIME properly (more on that here: https://docs.knime.com/2018-12/python_installation_guide/index.html)

GenerateUUIDExample3.knwf (13.6 KB)

3 Likes

Thank you very much!

1 Like