Connecting MySQL to Robocorp

Hello. I’m new in RPA. I tried to follow some tutorials and forums, when I tried this code to connect to my MySQL database, I got timeout error. Is there something that I miss? Thanks

*** Settings ***
Documentation     Template robot main suite.
Library        RPA.Browser.Selenium
Library    RPA.Database

*** Variables ***
${username}   root
${password}   root

*** Tasks ***
Minimal task
    Connect To Database    pymysql  angaran_capex  ${username}  ${password}  127.0.0.1  ${81}
    @{rows} =    Query   SELECT id,nama FROM bank
    FOR  ${row}  IN  @{rows}
        Log   ${row}
    END
    Disconnect From Database
    Log    Done.
    

Here is the result when I tried to run the robot

==============================================================================
Tasks :: Template robot main suite.                                           
==============================================================================
Minimal task                                                          | FAIL |
OperationalError: (2013, 'Lost connection to MySQL server during query')
------------------------------------------------------------------------------
Tasks :: Template robot main suite.                                   | FAIL |
1 task, 0 passed, 1 failed
==============================================================================
Output:  d:\Artajasa\RPA\DANA 2\output\output.xml
Log:     d:\Artajasa\RPA\DANA 2\output\log.html

Hi @rezakahfi03,

Your connection and code appear to be written correctly and it seems to have connected since the error states that you lost connection during the query. Does your data that you are returning contain any special characters? I believe some of these can cause the connection to be dropped.

Best,
Tim

Hello @Tim Thanks for your reply

There is no special character and I’m using simple database for testing. Here is the data in the table
image

I also modify it little for the password to blank because I’m not using password from default, but the result still same. I’m trying to connect to oracle too for the code that I commented, but I’m still finding how to add the oracle module. Would you mind to check that too or give me suggestion for the oracle? Thanks

*** Settings ***
Documentation     Template robot main suite.
Library        RPA.Browser.Selenium
Library    RPA.Database

*** Variables ***

# MYSQL
${username}   root
${password}   

# Oracle
# ${username}   C##hr
# ${password}   oracle

*** Tasks ***
Minimal task
    Connect To Database    pymysql  local  ${username}  ${password}  127.0.0.1  81
    @{rows} =    Query   SELECT * FROM bank;
    
    # Connect To Database    cx_oracle  local  ${username}  ${password}  127.0.0.1  1521
    # @{rows} =    Query   SELECT * FROM TEST_RPA;
    FOR  ${row}  IN  @{rows}
        Log   ${row}
    END
    Disconnect From Database
    Log    Done.

Hi @rezakahfi03,

I will take a look and get back to you.

Best,
Tim

This might or might not be relevant:

@rezakahfi03,

Based on what @jani sent is your connection still dropping during your query?

Best,
Tim

Hello @jani and @Tim , I tried to increase the timeout but still lost connection, same error. Actually, I already try the connection to oracle and success, and the time to connect to oracle is fast. So I don’t think the problem is time out. I try to change the library to DatabaseLibrary, that I’m using to Oracle and still lost connection. I follow the code from here to make connection and try simple select query

MySQL