public void AsyncAsTicks () { var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest()); var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), false); var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString)); TestAsyncDateTimeOffset (db); }
public async Task TestTimeSpan() { var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest()); var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), true); var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString)); await TestAsyncDateTime(db); }
public SQLiteDatabase(string DbPath) { var options = new SQLiteConnectionString(DbPath, true, key: "password"); database = new SQLiteConnection(options); database.CreateTable <Account>(); database.CreateTable <Currency>(); database.CreateTable <OptionDb>(); }
public void CreateDB() { string sqliteFilename = "myDb.db3"; string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); // Documents folder string path = Path.Combine(documentsPath, sqliteFilename); var platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroidN(); var param = new SQLiteConnectionString(path, false); var connection = new SQLiteConnection(platform, path); }
public SqlData() { this.CalcFilePath = Path.Combine(this.Dir, this.Filename); var options = new SQLiteConnectionString(this.CalcFilePath, true, key: "Fortnite"); this.Conn = new SQLiteConnection(options); this.Conn.CreateTable<RechnungItem>(); }
public SQLiteAsyncConnection GetConnection() { var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var path = Path.Combine(documentsPath, "MySQLite.db3"); var connectionString = new SQLiteConnectionString(path, false); var connectionWithLock = new SQLiteConnectionWithLock(new SQLitePlatformAndroid(), connectionString); return(new SQLiteAsyncConnection(() => connectionWithLock)); }
public void SQLiteSimpleCacheReplace_T_Test() { SQLiteConnectionString connstring = new SQLiteConnectionString("somepath", false, new Mocks.MockBlobSerializer()); SQLiteSimpleCache cache = new SQLiteSimpleCache(new Mocks.MockSqlLiteProvider(), connstring, new Mocks.MockByteSerializer()); cache.Replace <MockSQLiteData>("1", new MockSQLiteData()); Assert.AreEqual(1, MockBase.DeleteStatementsExecuted.Count); Assert.AreEqual(1, MockBase.InsertStatementsExecuted.Count); }
public DatabaseManager() { var DataSource = "database.db"; _sqliteOptions = new SQLiteConnectionString(DataSource, false); //GetUser(69); //GetUserFromDatabase(69); //Query("CREATE TABLE users (id INT PRIMARY KEY, discord_id INT, osu_id INT)"); }
public SqlData() { this.RezeptFilePath = Path.Combine(this.Dir, this.Filename); var options = new SQLiteConnectionString(this.RezeptFilePath, true, key: "geheim"); this.Conn = new SQLiteConnection(options); this.Conn.CreateTable <RezeptItem>(); }
public SQLite.SQLiteAsyncConnection GetAsyncConnection() { string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder string libraryPath = Path.Combine(documentsPath, "..", "Library"); // Library folder var path = Path.Combine(libraryPath, DBName); var param = new SQLiteConnectionString(path, false); var connection = new SQLiteAsyncConnection(path, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.SharedCache); return(connection); }
public void SQLiteSimpleCacheGet_T_Test() { SQLiteConnectionString connstring = new SQLiteConnectionString("somepath", false, new Mocks.MockBlobSerializer()); SQLiteSimpleCache cache = new SQLiteSimpleCache(new Mocks.MockSqlLiteProvider(), connstring, new Mocks.MockByteSerializer()); MockSQLiteData myObject = cache.Get <MockSQLiteData>("1"); //The SQLIteConnection seems to run the command twice //this might be a bug in SQLite that is fixed later thus less then or equal is used. Assert.LessOrEqual(1, MockBase.SelectStatementsExecuted.Count); }
public SqliteRepository(ISQLitePlatform platform, ILocalStorage storage, DbPath dbpath, string dbfile = "data.db") { string dbFullPath = Path.Combine(dbpath.Path, dbfile); this.connectionString = new SQLiteConnectionString(dbFullPath, true, openFlags: SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.SharedCache); this.platform = platform; this.storage = storage; this.dbPath = Path.GetDirectoryName(this.connectionString.DatabasePath); }
public void SQLiteSimpleCacheRemoveAllTest() { SQLiteConnectionString connstring = new SQLiteConnectionString("somepath", false, new Mocks.MockBlobSerializer()); SQLiteSimpleCache cache = new SQLiteSimpleCache(new Mocks.MockSqlLiteProvider(), connstring, new Mocks.MockByteSerializer()); cache.RemoveAll(new List <string> { "1", "2", "3" }); Assert.AreEqual(3, MockBase.DeleteStatementsExecuted.Count); }
public async Task SQLiteSimpleCacheGetAll_T_AsyncTest() { SQLiteConnectionString connstring = new SQLiteConnectionString("somepath", false, new Mocks.MockBlobSerializer()); SQLiteSimpleCache cache = new SQLiteSimpleCache(new Mocks.MockSqlLiteProvider(), connstring, new Mocks.MockByteSerializer()); await cache.GetAllAsync <MockSQLiteData>(new List <string>(){ "0" }); //The SQLIteConnection seems to run the command twice //this might be a bug in SQLite that is fixed later thus less then or equal is used. Assert.LessOrEqual(1, MockBase.SelectStatementsExecuted.Count); }
public static SQLiteConnection GetDbConnection() { //var option = new SQLiteConnectionString(DbPath, true, key: "pCBR8Jg7n6lHPcwh"); var option = new SQLiteConnectionString(DbPath); var liteConnection = new SQLiteConnection(option); liteConnection.CreateTable <AnimalsInsect>(); liteConnection.CreateTable <AnimalsFish>(); return(liteConnection); }
public SqlDaten() { this.StartlisteFilePath = Path.Combine(this.Dir, this.Filename); var options = new SQLiteConnectionString(this.StartlisteFilePath, true); this.Conn = new SQLiteConnection(options); this.Conn.CreateTable <Starter>(); }
public Task InitialiseDebugAsync() { return(Task.Run(async() => { var path = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, "GlyphData.db"); if (File.Exists(path)) { File.Delete(path); } SQLiteConnectionString connection = new SQLiteConnectionString(path); using (SQLiteConnection con = new SQLiteConnection(connection)) { PrepareDatabase(con); } await PopulateMDL2Async(connection).ConfigureAwait(false); await PopulateFontAsync <FontAwesomeGlyph>(connection, "FontAwesome.txt").ConfigureAwait(false); await PopulateFontAsync <MaterialDesignIconsLegacyGlyph>(connection, "materialdesignicons.txt").ConfigureAwait(false); await PopulateFontAsync <MaterialDesignIconsGlyph>(connection, "materialdesignicons5.txt").ConfigureAwait(false); await PopulateFontAsync <IcoFontGlyph>(connection, "icofont.txt").ConfigureAwait(false); var unicode = await PopulateUnicodeAsync(connection).ConfigureAwait(false); await PopulateDingsAsync <WebdingsGlyph>(connection, unicode, "Webdings"); await PopulateDingsAsync <WingdingsGlyph>(connection, unicode, "Wingdings"); await PopulateDingsAsync <Wingdings2Glyph>(connection, unicode, "Wingdings2"); await PopulateDingsAsync <Wingdings3Glyph>(connection, unicode, "Wingdings3"); using (SQLiteConnection con = new SQLiteConnection(connection)) { con.Execute($"DROP TRIGGER IF EXISTS insert_trigger_{MDL2_SEARCH_TABLE}"); con.Execute($"DROP TRIGGER IF EXISTS insert_trigger_{UNICODE_SEARCH_TABLE}"); con.Execute($"INSERT INTO {MDL2_SEARCH_TABLE}({MDL2_SEARCH_TABLE}) VALUES('optimize')"); con.Execute($"INSERT INTO {UNICODE_SEARCH_TABLE}({UNICODE_SEARCH_TABLE}) VALUES('optimize')"); foreach (SearchTarget target in SearchTarget.KnownTargets) { con.Execute($"DROP TRIGGER IF EXISTS insert_trigger_{target.SearchTable}"); con.Execute($"INSERT INTO {target.SearchTable}({target.SearchTable}) VALUES('optimize')"); } } using (SQLiteConnection con = new SQLiteConnection(connection)) { con.Execute("VACUUM \"main\""); con.Execute("VACUUM \"temp\""); con.Execute("VACUUM"); } _connection = new SQLiteConnection(connection); })); }
public SQLiteAsyncConnection GetConnection() { var sqliteFilename = "AAAAAAAA.db3"; string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); // Documents folder var path = Path.Combine(documentsPath, sqliteFilename); var platform = new SQLitePlatformAndroid(); var param = new SQLiteConnectionString(path, false); var connection = new SQLiteAsyncConnection(() => new SQLiteConnectionWithLock(platform, param)); return(connection); }
public LocalDB(string dbPath) { //this connection string will encrpyt the database with a keyword SQLiteConnectionString connectionString = new SQLiteConnectionString(dbPath, true, "combination"); _database = new SQLiteAsyncConnection(connectionString); _database.CreateTableAsync <Credential>().Wait(); _database.CreateTableAsync <WifiCredential>().Wait(); _database.CreateTableAsync <BankCredential>().Wait(); _database.CreateTableAsync <SocialMediaCredential>().Wait(); }
private SQLiteConnectionWithLock GetSyncConnection() { var rootFolder = FileSystem.Current.LocalStorage; var dbPath = Path.Combine(rootFolder.Path, "app.db"); var sqliteConnectionString = new SQLiteConnectionString(dbPath, true); var platformFactory = DependencyService.Get <ISQLitePlatformFactory>(); var platform = platformFactory.GetInstance(); return(new SQLiteConnectionWithLock(platform, sqliteConnectionString)); }
public SqliteEventStore(ISQLitePlatform sqLitePlatform, string databasePath, GetUtcNow getUtcNow = null) { Ensure.That(sqLitePlatform, "sqLitePlatform").IsNotNull(); Ensure.That(databasePath, "databasePath").IsNotNull(); _getUtcNow = getUtcNow ?? SystemClock.GetUtcNow; _connectionPool = new SQLiteConnectionPool(sqLitePlatform); var connectionString = new SQLiteConnectionString(databasePath, false); _getConnection = () => _connectionPool.GetConnection(connectionString); }
public SQLiteAsyncConnection GetConnection() { var sqliteFilename = "AAAAAAAAA.db3"; string documentsPath = Windows.Storage.ApplicationData.Current.LocalFolder.Path; var path = Path.Combine(documentsPath, sqliteFilename); var platform = new SQLitePlatformWinRT(); var param = new SQLiteConnectionString(path, false); var connection = new SQLiteAsyncConnection(() => new SQLiteConnectionWithLock(platform, param)); return(connection); }
public async Task SQLiteSimpleCacheSetAllAsync_T_Test() { SQLiteConnectionString connstring = new SQLiteConnectionString("somepath", false, new Mocks.MockBlobSerializer()); SQLiteSimpleCache cache = new SQLiteSimpleCache(new Mocks.MockSqlLiteProvider(), connstring, new Mocks.MockByteSerializer()); await cache.SetAllAsync <MockSQLiteData>(new Dictionary <string, MockSQLiteData>() { { "0", new MockSQLiteData() }, { "1", new MockSQLiteData() } }); Assert.AreEqual(2, MockBase.InsertOrReplaceStatementsExecuted.Count); }
public SQLiteAsyncConnection GetConnection() { var sqliteFilename = "AAAAAAAAA.db3"; string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder string libraryPath = Path.Combine(documentsPath, "..", "Library"); // Library folder var path = Path.Combine(libraryPath, sqliteFilename); var platform = new SQLitePlatformIOS(); var param = new SQLiteConnectionString(path, false); var connection = new SQLiteAsyncConnection(() => new SQLiteConnectionWithLock(platform, param)); return(connection); }
//public SQLiteAsyncConnection GetConnection() //{ // var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // var path = Path.Combine(documentsPath, "MySQLite.db3"); // return new SQLiteAsyncConnection(path); //} public SQLiteAsyncConnection GetConnection() { var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var path = Path.Combine(documentsPath, "MySQLite.db3"); var connectionString = new SQLiteConnectionString(path, false); var connectionWithLock = new SQLiteConnectionWithLock(new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid(), connectionString); var connection = new SQLiteAsyncConnection(() => connectionWithLock); return(connection); }
public DataService() { var sqlitePlatform = new SQLitePlatformWinRT(); var connectionString = Path.Combine(ApplicationData.Current.LocalFolder.Path, FileName); var sqliteConnectionString = new SQLiteConnectionString(connectionString, false); baseConnection = new SQLiteConnectionWithLock(sqlitePlatform, sqliteConnectionString); connection = new SQLiteAsyncConnection(() => baseConnection); EnsureTableExists <FolderData>(); EnsureTableExists <NoteData>(); }
static Database() { //if (File.Exists (Util.DatabaseFile)) // File.Delete (Util.DatabaseFile); var platform = new SQLitePlatformIOS(); var param = new SQLiteConnectionString(DatabaseFile, false); if (Main == null) { Main = new Database(() => new SQLiteConnectionWithLock(platform, param)); } }
public SQLiteConnectionWithLock GetConnectionWithLock() { if (persistentConnection == null) { var dbFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), Constants.DB_FILE_NAME); var platform = new SQLitePlatformAndroid(); var connectionString = new SQLiteConnectionString(dbFilePath, true); persistentConnection = new SQLiteConnectionWithLock(platform, connectionString); } return(persistentConnection); }
private SQLiteConnectionWithLock SetupReadConnection() { var databaseFile = Path.Combine(GetDataPath(), "readDatabase.db"); var connectionString = new SQLiteConnectionString(databaseFile, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.SharedCache, true, null); var readConn = new SQLiteConnectionWithLock(connectionString) { BusyTimeout = TimeSpan.FromSeconds(2) }; ConfigureConnection(readConn); return(readConn); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); var platform = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS(); string dbPath = GetDatabasePath("RealmPerformance.db"); var param = new SQLiteConnectionString(dbPath, false); var connection = new SQLiteAsyncConnection(() => new SQLiteConnectionWithLock(platform, param)); LoadApplication(new RealmPerformance.App(connection)); return(base.FinishedLaunching(app, options)); }
public void SetUp() { if (_sqliteConnectionPool != null) { _sqliteConnectionPool.Reset(); } _path = Path.Combine(Path.GetTempPath(), DatabaseName); // delete old db file File.Delete(_path); _connectionParameters = new SQLiteConnectionString(_path, false); _sqliteConnectionPool = new SQLiteConnectionPool(_sqlite3Platform); }
public void CloseConnection(SQLiteConnectionString connectionString) { var key = connectionString.UniqueKey; Entry entry; lock (_entriesLock) { if (_entries.TryGetValue(key, out entry)) { _entries.Remove(key); } } entry?.Close(); }
public void SetUp() { if (_sqliteConnectionPool != null) { _sqliteConnectionPool.Reset(); } _path = Path.Combine(Path.GetTempPath(), DatabaseName); // delete old db file File.Delete(_path); _connectionParameters = new SQLiteConnectionString(_path, false); _sqliteConnectionPool = new SQLiteConnectionPool(_sqlite3Platform); }
public void AsyncAsTicks () { var sqLiteConnectionString = new SQLiteConnectionString(TestPath.CreateTemporaryDatabase(), false); var db = new SQLiteAsyncConnection(() => new SQLiteConnectionWithLock(new SQLitePlatformTest(), sqLiteConnectionString)); TestAsyncDateTimeOffset (db); }
public async Task AsyncAsTicks() { var sqLiteConnectionString = new SQLiteConnectionString(TestPath.CreateTemporaryDatabase(), true); var db = new SQLiteAsyncConnection(() => new SQLiteConnectionWithLock(new SQLitePlatformTest(), sqLiteConnectionString)); await TestAsyncDateTime(db, sqLiteConnectionString.StoreDateTimeAsTicks); }
public async Task AsyncAsString() { var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest()); var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), false); var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString)); await TestAsyncDateTime(db, sqLiteConnectionString.StoreDateTimeAsTicks); }
public void SetUp() { var databaseFile = TestPath.CreateTemporaryDatabase(); _connectionParameters = new SQLiteConnectionString(databaseFile, false); }