I need the ability to backup a sqlite database without locking it for inserts. I can do this with Sql Server just fine but i was hoping there was a way to do this with Sqlite.
The backup code is:
using (var location = new SQLiteConnection(sqliteConnectionString))
using (var destination = new SQLiteConnection(buConnectionString))
{
location.Open();
destination.Open();
location.BackupDatabase(destination, "main", "main", -1, null, 0);
}
and the code that is throwing there error is:
using (var connection = new SQLiteConnection(constring))
{
connection.Open();
using (var cmd = new SQLiteCommand(sql, connection))
{
using (var tx = connection.BeginTransaction())
{
foreach (var t in data)
{
cmd.Parameters.AddWithValue("$Id", t.TagId);
cmd.Parameters.AddWithValue("$StampedIn", t.StampedIn.
ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture));
cmd.Parameters.AddWithValue("$StampedOut", t.StampedOut.
ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture));
}
cmd.ExecuteNonQuery();
tx.Commit();
}
}
connection.Close();
}
The data object has roughly 3000 items in it and each is logged/updated once a second. Any ideas on how to do a backup with out locking the database would be helpful. Thanks everyone