c# - Copying a large amount of rows between two tables in two different mysql databases -


I have a database, let's call it database A , and another databaseb In MySQL

I have a SQL statement that raises data from Database A (approximately 1 million lines) and it needs to be inserted into database B.

To read data from Database A, I am using a MySqlDataReader which has 1 million rows. Now I would like to write them in Database B.

Whatever I have tried to do is iterative through each line in the data reader, and write the database with the simple INSERT stored procedure It is taking a very long time.

I looked at the SQL Bulk Data Copy with C #, though I do not want to use external files.

What options do I have?

a simple query

  select mysqldb1.table1 * mysqldb2 From .table2   

This is executed by MySQL engine directly by preventing any passage of data from MySQL and your code

  string cmdText = "mysqldb1 Include in Table1 SELECT * mysqldb2.table2 "; (MySqlConnection cnn = Using MySqlConnection (.....)) (MySqlCommand CMD = New MySqlCommand (cmdText, cnn)) (cnn.Open ()); Int rows = CMD.exequintonquine (); Console.WriteLine (rows); }   

In a more complex scenario (for example, you need to repeat the operation and the target table is not present at the start) You can write a question like this < Pre> string cmdText = @ "drop table if mysqldb1.table1; create table mysqldb1.table1 such as mysqldb2.table2; mysqldb1.table1 * from mysqldb2.table2"; (MySqlConnection cnn = New MySqlConnection (.....)) (MySqlCommand cmd = New MySqlCommand (cmdText, cnn)) {......}

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -