I’m trying to implement the export functionality for my database application. I’m using C# and have the SQlite wrapper for C# that I’m using. Pardon my ignorance of database concepts/common usage, this is my first database application.
Export :
Easily enough, the SQLite databases are stored in a single s3db file. So, to export, I simply need to copy that file using System.IO.File.Copy? Is that the best way to do this? Lastly, with export, do I need to close all database connections before copying the file? Again, best practices for this situation would be a great help… I’m unsure as to a few things in this situation. For example…
What if the database is huge and the copy takes a while? The user could start a export, then immediately go and try to insert something into the database, which would obviously be an issue. Should I lock the program while copying?
As always, thank you for any assistance.
I did similar functionality for SQL Server CE, which is very similar to sqlite in concept. The safest way to handle it is how you suggested: Close all database connections and prevent the user from opening anymore (I handled this with a modal window over the entire application that showed progress of the backup). Again, I haven’t done it with sqlite per se, but with SQL Server CE, it was a simple file copy.
To make a window modal over the entire application for a WinForms app, simply use MessageBox.Show(), and do not specify an owner.