using System.Data;
using System.Data.SQLite;
using System.Threading.Tasks;
namespace MediaBrowser.ServerApplication.Native
{
    /// 
    /// Class Sqlite
    /// 
    public static class Sqlite
    {
        /// 
        /// Connects to db.
        /// 
        /// The db path.
        /// Task{IDbConnection}.
        /// dbPath
        public static async Task OpenDatabase(string dbPath)
        {
            var connectionstr = new SQLiteConnectionStringBuilder
            {
                PageSize = 4096,
                CacheSize = 4096,
                SyncMode = SynchronizationModes.Normal,
                DataSource = dbPath,
                JournalMode = SQLiteJournalModeEnum.Wal
            };
            var connection = new SQLiteConnection(connectionstr.ConnectionString);
            await connection.OpenAsync().ConfigureAwait(false);
            return connection;
        }
    }
}