cancel
Showing results for 
Search instead for 
Did you mean: 

Bulk Insert into MySQL Table

JongjongOclari1
Level 3

Hi All,

Is there a way to do a bulk insert into MySQL table.

Thanks



------------------------------
Jongjong Oclarit
------------------------------
1 BEST ANSWER

Helpful Answers

FWIW - There is a MySQL VBO available on the DX.

https://digitalexchange.blueprism.com/dx/entry/9648/solution/blue-prism---mysql-utility

Cheers,



------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

View answer in original post

5 REPLIES 5

KristianHolm1
Level 5

Hi jongjong

Execute the sql statement and insert rows from a file.

"BULK INSERT

FROM '"&[path filename]&"' WITH (fieldterminator = ' ', rowterminator = '\n')"



------------------------------
Kristian Holm
RPA programmer
PenSam (Pension Company)
Copenhagen Denmark
------------------------------

Kristian Holm RPA programmer PenSam (Pension Company) Copenhagen Denmark

PabloSarabia
Level 11

Hello!

I think the best way is to use MySqlBlukLoader. Here is a link of the documentation https://dev.mysql.com/doc/connector-net/en/connector-net-programming-bulk-loader.html

Basically, this piece of code:

string connStr = "server=localhost;user=root;database=test;port=3306;password=******";
MySqlConnection conn = new MySqlConnection(connStr);
MySqlBulkLoader bl = new MySqlBulkLoader(conn);
bl.Local = true;
bl.TableName = "Career";
bl.FieldTerminator = "\t";
bl.LineTerminator = "\n";
bl.FileName = "c:/career_data.txt";
conn.Open();
bl.Load();

I hope I helped you



------------------------------
Pablo Sarabia
Programmer
Altamira AM
------------------------------

JongjongOclari1
Level 3

Hi Guys,

Thanks for the reply I will try your suggestion once i will get the data from a file.

For now i will use this line of code below as data needs to be validated first.

INSERT INTO projects(name, start_date, end_date)

VALUES ('AI for Marketing','2019-08-01','2019-12-31'), ('ML for Sales','2019-05-15','2019-11-20');

Thanks



------------------------------
Jongjong Oclarit
------------------------------

FWIW - There is a MySQL VBO available on the DX.

https://digitalexchange.blueprism.com/dx/entry/9648/solution/blue-prism---mysql-utility

Cheers,



------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

Hi, 

This approach will work only if SQL server has access to the file location, in many cases the Bot will get the Bulk Data from somewhere and need to insert it into DB, storing it into the file system may not be an option. also looping records one by one will take ages.

What could be an option here?



------------------------------
Bassam Yousif
Director
DAR-ME
Amman
------------------------------