def test_pgsql_driver(self): db = dbpool.make_dbpool({ 'driver': 'pgsql', 'database': 'test', 'user': '******', 'password': '******', }) yield db.runOperation("DROP TABLE IF EXISTS twoost_the_table") yield db.runOperation("CREATE TABLE twoost_the_table (x int, y int)") yield db.runOperation("INSERT INTO twoost_the_table (x, y) VALUES (%s, %s)", [1, 2]) yield db.runOperation("INSERT INTO twoost_the_table (x, y) VALUES (%s, %s)", [10, 20]) rows = yield db.runQuery("SELECT x FROM twoost_the_table") self.assertEquals([{'x': 1}, {'x': 10}], map(dict, rows)) def delete_rows(txn): txn.execute("DELETE FROM twoost_the_table") yield db.runInteraction(delete_rows) rows = yield db.runQuery("SELECT x FROM twoost_the_table") self.assertEquals([], rows) yield db.runOperation("DROP TABLE IF EXISTS twoost_the_table") db.close()
def test_pgsql_driver(self): db = dbpool.make_dbpool({ 'driver': 'pgsql', 'database': 'test', 'user': '******', 'password': '******', }) yield db.runOperation("DROP TABLE IF EXISTS twoost_the_table") yield db.runOperation("CREATE TABLE twoost_the_table (x int, y int)") yield db.runOperation( "INSERT INTO twoost_the_table (x, y) VALUES (%s, %s)", [1, 2]) yield db.runOperation( "INSERT INTO twoost_the_table (x, y) VALUES (%s, %s)", [10, 20]) rows = yield db.runQuery("SELECT x FROM twoost_the_table") self.assertEquals([{'x': 1}, {'x': 10}], map(dict, rows)) def delete_rows(txn): txn.execute("DELETE FROM twoost_the_table") yield db.runInteraction(delete_rows) rows = yield db.runQuery("SELECT x FROM twoost_the_table") self.assertEquals([], rows) yield db.runOperation("DROP TABLE IF EXISTS twoost_the_table") db.close()
def test_sqlite3_driver(self): db = dbpool.make_dbpool({ 'driver': 'sqlite', 'database': "$TEST_TMP_DIR/test.db", }) yield db.runOperation("CREATE TABLE twoost_the_table (x, y)") yield db.runOperation( "INSERT INTO twoost_the_table (x, y) VALUES (?, ?)", [1, 2]) yield db.runOperation( "INSERT INTO twoost_the_table (x, y) VALUES (?, ?)", [10, 20]) rows = yield db.runQuery("SELECT x FROM twoost_the_table") self.assertEquals([{'x': 1}, {'x': 10}], map(dict, rows)) def delete_rows(txn): txn.execute("DELETE FROM twoost_the_table") yield db.runInteraction(delete_rows) rows = yield db.runQuery("SELECT x FROM twoost_the_table") self.assertEquals([], rows) yield db.runOperation("DROP TABLE twoost_the_table") db.close()
def test_sqlite3_driver(self): db = dbpool.make_dbpool({ 'driver': 'sqlite', 'database': "$TEST_TMP_DIR/test.db", }) yield db.runOperation("CREATE TABLE twoost_the_table (x, y)") yield db.runOperation("INSERT INTO twoost_the_table (x, y) VALUES (?, ?)", [1, 2]) yield db.runOperation("INSERT INTO twoost_the_table (x, y) VALUES (?, ?)", [10, 20]) rows = yield db.runQuery("SELECT x FROM twoost_the_table") self.assertEquals([{'x': 1}, {'x': 10}], map(dict, rows)) def delete_rows(txn): txn.execute("DELETE FROM twoost_the_table") yield db.runInteraction(delete_rows) rows = yield db.runQuery("SELECT x FROM twoost_the_table") self.assertEquals([], rows) yield db.runOperation("DROP TABLE twoost_the_table") db.close()