-
Notifications
You must be signed in to change notification settings - Fork 106
Conditional Rows Export for Each Table
Adrian Voo edited this page Sep 16, 2021
·
2 revisions
Sample codes:
void Export()
{
var dic = new Dictionary<string,string>();
dic["tableA"] = "SELECT * FROM `tableA`;";
dic["tableB"] = "SELECT * FROM `tableB` WHERE 1 = 2;";
dic["tableC"] = "SELECT * FROM `tableC` WHERE membershipid = 1;";
dic["tableD"] = "SELECT id,name,address,tel FROM `tableD`;";
dic["tableE"] = "SELECT * FROM `tableE` WHERE dateregister >= '2014-01-01 00:00:00' and dateregister <= '2014-12-31 23:59:59';";
using (MySqlConnection conn = new MySqlConnection(connectionString))
{
using (MySqlCommand cmd = new MySqlCommand())
{
using (MySqlBackup mb = new MySqlBackup(cmd))
{
cmd.Connection = conn;
conn.Open();
mb.ExportInfo.TablesToBeExportedDic = dic;
mb.ExportToFile("C:\\backup.sql");
}
}
}
}
Explain:
- tableA - All rows will be exported.
- tableB - No rows will be exported.
- tableC - Only rows with membershipid = 1 will be exported.
- tableD - Only 4 columns (id, name, address, tel) of data will be exported for all rows.
- tableE - Only export rows which the dateregister is within specific date range.
https://github.com/MySqlBackupNET/MySqlBackup.Net/issues/79