SQLite Compare Utility

Introduction
SQLite Compare is a small and fast utility that can compare two SQLite database files for schema and data differences.
It was born out of my frustration of finding a decent DB comparison tool for SQLite database files.
Initially, I tried to sell it as a commercial product. After some time, I realized that this is not the course I'd like to pursue and thus I've decided to release it as open source to the SQLite community.
I hope it will be useful for your purposes.
Using the Code
The SQLite Compare utility is composed of the following C# projects:
- SQLiteParser project - Responsible to parse SQLite SQL schema text and produce an abstract syntax tree of the entire database schema. This is mandatory if we want to be able to compare the schema differences of two different SQLite databases.
- DiffControl project - Contains a Windows-Forms
DIFF
control that I've developed so that I can provide the user with the ability to view differences in SQL schema between two SQLite databases and to modify these schemas. It can be useful in other contexts as well so it merited a project of its own. The control itself was written by me, but the diff engine itself was taken from another project in CodeProject. - FastGrid project - During the development of the data differences view, I came to the conclusion that the standard C# data grid view control does not have the ability to work with millions of rows. Even when working in
VirtualMode
, it stores tons of information in memory which makes it impractical for displaying large amounts of information. For this purpose, I developed a very lightweight control (WindowsForms
) that can support this fast enough. - Liron.Windows.Forms project - Contains the multi-panel control I've developed. I wrote a separate article about this in CodeProject (search for multi panel). Basically - it provides the ability to author multiple pages in a single design time control (like working with a tab control, but without the tabs...)
- AutomaticUpdates - This project was responsible to check if there is a newer software version in the web site and download it if necessary. It is now obsolete, but a quick reading of the code can reveal what I did and may be useful to you if you intend to support live updates in your application.
- UndoRedo - A small library I wrote to support UNDO/REDO operations. May be useful in other applications as well.
- Be.Windows.Forms.HexBox - A very nice control I've downloaded from the internet which supports Hex editing. I used it for editing BLOB field values.
- SQLiteTurbo - the main application code. All the various forms are here.
- Misc libraries I've downloaded from open source authors: Garden Point Parser Generator SDK (used to build the SQLite parser code), Log4NET (logging), Puzzle Syntax Box (displaying change scripts)
Since I don't have much time and the code is reasonably documented, I've decided to skip on the explanations of the utility's internal structure and jump right into the instructions of how to use it.
Basically - in order to compare two SQLite database files, you need to click the "Compare..." button. This will open up the "Comparison Details" dialog in which you'll fill in the paths to both SQLite database files and choose the comparison mode:
- Compare schema only- For comparing only SQL schema differences. This will perform very quickly but will not compare any data.
- Compare schema and data - For comparing both SQL schema differences and all table data rows. Depending on the databases - this can be a lengthy operation..
Once the comparison is completed - the utility will display a table with all the differences that were found and allow the user to drill down and show the specific differences:

When drilling down to a specific DB object, we'll get the detailed difference. For example:

At this point, you can copy differences between the two databases and the utility will automatically update the relevant database schema.
In case you need to compare the data rows of the two tables - you can click the "Compare data" button and you'll get the following tab:

This tab provides you with the ability to view the data differences between the rows and to copy differences from one table to the other.
Points of Interest
The Gardens Point Parser Generator project proved invaluable resource when building the SQLite parser. In my opinion, it's one of the best SDKs in C# for building parsers and lexical analyzers.
FastGrid
and DiffControl
projects were very fun to develop. They proved that it is not too difficult to build even complex seeming controls in a short amount of time and are a testament to the fantastic work done by Microsoft and the open source community. Specifically - the Diff engine algorithm was contributed by another CodeProject member.
The SQLite database libraries and the .NET provider are amazingly versatile and robust pieces of code. The work done by Dr. Richard Hipp (SQLite C libraries) and Robert Simpson (C# SQLite Provider) is simply fantastic!
History
- 3rd July, 2011: Version 2.5 - Initial version (open source)
- 5th July, 2011: Fixed the Setup.nsi file to use the correct files in the Release folder
发表评论
RqL9KW Yes. It should do the job. If it doesn at send us an email.
D92YYz Just a smiling visitor here to share the love (:, btw great design.
3qzGAG You are so cool! I don at suppose I ave read through a single thing like this
pID835 Thanks a lot for the article post.Really looking forward to read more. Cool.
Ig32EZ We at present do not very personal an automobile however anytime I purchase it in future it all definitely undoubtedly be a Ford style!
jGboV7 Wow! Thank you! I always wanted to write on my website something like that. Can I take a portion of your post to my site?
w9D845 Some really quality articles on this web site , bookmarked.
nHIIDy Very interesting subject , thankyou for putting up.
nRe4gy You are my inspiration , I have few blogs and often run out from to brand.
YezrRt I cannot thank you enough for the blog article.Really thank you! Want more.
scgzzc wow, awesome article post.Really thank you!
TGcCqV Thanks for helping out, excellent info. The health of nations is more important than the wealth of nations. by Will Durant.
CremTj Hey, thanks for the article post.Much thanks again. Really Cool.
LtioYj F*ckin' amazing things here. I am very happy to peer your post. Thanks a lot and i'm having a look ahead to touch you. Will you please drop me a e-mail?
Aro2dp Thanks for the auspicious writeup. It actually was a leisure account it. Look complicated to far added agreeable from you! By the way, how can we keep in touch?
virGFN I was suggested this blog by my cousin. I'm not sure whether this post is written by him as nobody else know such detailed about my difficulty. You're incredible! Thanks!
71FV4o Hi there, I discovered your website by means of Google even as searching for a comparable matter, your website came up, it seems to be great. I've bookmarked it in my google bookmarks.
5a6nms Very good written article. It will be helpful to everyone who usess it, including me. Keep doing what you are doing - can'r wait to read more posts.
CxnQgi Thanks for the article post.Thanks Again. Really Cool.
HkLfj8 I have been examinating out some of your stories and i must say pretty nice stuff. I will make sure to bookmark your blog.
w3lWmJ Hey, thanks for the blog. Really Cool.
eqH0XA Thanks again for the post.Much thanks again. Awesome.
nhao8k I really liked your post.Really thank you! Cool.
UL8jy1 Great blog article.Thanks Again. Much obliged.
tvl00d Thank you ever so for you article post.Really thank you! Cool.
rMQtMB wow, awesome blog post.Much thanks again. Will read on...
ESFuIW I really like and appreciate your blog post.Really thank you! Awesome.
KEqxaN Thank you ever so for you article post.Really thank you! Cool.
XrBU0W Thanks so much for the post.Thanks Again.