def test_commit(self): self.db.execute("BEGIN") self.db.execute("INSERT INTO cs50 (val) VALUES('foo')") self.db.execute("COMMIT") # Load a new database instance to confirm the INSERT was committed db2 = SQL(self.db_url) self.assertEqual(db2.execute("SELECT val FROM cs50"), [{"val": "foo"}])
def test_autocommit(self): self.assertEqual( self.db.execute("INSERT INTO cs50(val) VALUES('foo')"), 1) self.assertEqual( self.db.execute("INSERT INTO cs50(val) VALUES('bar')"), 2) # Load a new database instance to confirm the INSERTs were committed db2 = SQL(self.db_url) self.assertEqual(db2.execute("DELETE FROM cs50 WHERE id < 3"), 2)
def setUpClass(self): open("test.db", "w").close() self.db = SQL("sqlite:///test.db")
def setUpClass(self): self.db = SQL("postgresql://postgres@localhost/test")
def setUpClass(self): self.db = SQL("mysql://root@localhost/test")
def setUpClass(self): open("test.db", "w").close() self.db = SQL("sqlite:///test.db") open("test1.db", "w").close() self.db1 = SQL("sqlite:///test1.db", foreign_keys=True)
def setUpClass(self): self.db = SQL("sqlite:///test.db") self.db1 = SQL("sqlite:///test1.db", foreign_keys=True)
def setUpClass(self): self.db = SQL("sqlite:///test.db")
def setUpClass(self): open("test.db", "w").close() self.db_url = "sqlite:///test.db" self.db = SQL(self.db_url) print("\nSQLite tests")
def setUpClass(self): self.db_url = "postgresql://postgres@localhost/test" self.db = SQL(self.db_url) print("\nPOSTGRES tests")
def setUpClass(self): self.db_url = "mysql://root@localhost/test" self.db = SQL(self.db_url) print("\nMySQL tests")