Click here to Skip to main content
15,886,031 members
Articles / Desktop Programming / Windows Forms

SQLite Compare Utility

Rate me:
Please Sign up or sign in to vote.
4.89/5 (68 votes)
21 Feb 2015LGPL35 min read 281.8K   37.1K   131  
Utility for comparing two SQLite database files for both structure and data
using System;
using System.Collections.Generic;
using System.Text;

namespace SQLiteTurbo
{
    /// <summary>
    /// Encapsulates all the necessary comparison parameters.
    /// </summary>
    public class CompareParams
    {
        #region Constructors
        /// <summary>
        /// Constructs comparison parameters object
        /// </summary>
        /// <param name="left">The path to the left DB file</param>
        /// <param name="right">The path to the right DB file</param>
        /// <param name="ctype">Associated comparison type</param>
        public CompareParams(string left, string right, ComparisonType ctype, bool compareBlobFields)
        {
            _left = left;
            _right = right;
            _ctype = ctype;
            _compareBlobFields = compareBlobFields;
        }
        #endregion

        #region Public Properties
        /// <summary>
        /// Path to the left DB file to compare
        /// </summary>
        public string LeftDbPath
        {
            get { return _left; }
        }

        /// <summary>
        /// Path to right DB file to compare
        /// </summary>
        public string RightDbPath
        {
            get { return _right; }
        }

        /// <summary>
        /// The comparision type to use
        /// </summary>
        public ComparisonType ComparisonType
        {
            get { return _ctype; }
            set { _ctype = value; }
        }

        /// <summary>
        /// TRUE means that the compare worker will also compare BLOB field values
        /// </summary>
        public bool IsCompareBlobFields
        {
            get { return _compareBlobFields; }
            set { _compareBlobFields = value; }
        }
        #endregion

        #region Private Variables
        private string _left;
        private string _right;
        private ComparisonType _ctype = ComparisonType.None;
        private bool _compareBlobFields;
        #endregion
    }

    /// <summary>
    /// Provides various options to the comparison process.
    /// </summary>
    public enum ComparisonType
    {
        /// <summary>
        /// Illegal value
        /// </summary>
        None = 0,

        /// <summary>
        /// Compare the schema only
        /// </summary>
        CompareSchemaOnly = 1,

        /// <summary>
        /// Compare both schema and data stored in DB tables.
        /// </summary>
        CompareSchemaAndData = 2,
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Software Developer
Israel Israel
My name is Liron Levi and I'm developing software for fun & profit for 15 years already.

Comments and Discussions