diff options
| author | Eric Reed <ebr@mediabrowser3.com> | 2013-09-25 14:32:36 -0400 |
|---|---|---|
| committer | Eric Reed <ebr@mediabrowser3.com> | 2013-09-25 14:32:36 -0400 |
| commit | c02c0db35af078e1a78897aecdade2efe57d3f06 (patch) | |
| tree | af9ef64305efd2e353a202c27b188d2c44cd9b5b /MediaBrowser.ServerApplication/Native/Sqlite.cs | |
| parent | c6e57c6448c04998bcae5a906e7a064300542e75 (diff) | |
| parent | 2d9b48d00fd31aaa96676c82a054b2794493fbf9 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.ServerApplication/Native/Sqlite.cs')
| -rw-r--r-- | MediaBrowser.ServerApplication/Native/Sqlite.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/MediaBrowser.ServerApplication/Native/Sqlite.cs b/MediaBrowser.ServerApplication/Native/Sqlite.cs new file mode 100644 index 000000000..cc20952d7 --- /dev/null +++ b/MediaBrowser.ServerApplication/Native/Sqlite.cs @@ -0,0 +1,36 @@ +using System.Data; +using System.Data.SQLite; +using System.Threading.Tasks; + +namespace MediaBrowser.ServerApplication.Native +{ + /// <summary> + /// Class Sqlite + /// </summary> + public static class Sqlite + { + /// <summary> + /// Connects to db. + /// </summary> + /// <param name="dbPath">The db path.</param> + /// <returns>Task{IDbConnection}.</returns> + /// <exception cref="System.ArgumentNullException">dbPath</exception> + public static async Task<IDbConnection> 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; + } + } +} |
