예제 #1
0
    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"}])
예제 #2
0
    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)
예제 #3
0
 def setUpClass(self):
     open("test.db", "w").close()
     self.db = SQL("sqlite:///test.db")
예제 #4
0
 def setUpClass(self):
     self.db = SQL("postgresql://postgres@localhost/test")
예제 #5
0
 def setUpClass(self):
     self.db = SQL("mysql://root@localhost/test")
예제 #6
0
파일: sql.py 프로젝트: tejasvi/python-cs50
 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)
예제 #7
0
 def setUpClass(self):
     self.db = SQL("sqlite:///test.db")
     self.db1 = SQL("sqlite:///test1.db", foreign_keys=True)
예제 #8
0
 def setUpClass(self):
     self.db = SQL("sqlite:///test.db")
예제 #9
0
 def setUpClass(self):
     open("test.db", "w").close()
     self.db_url = "sqlite:///test.db"
     self.db = SQL(self.db_url)
     print("\nSQLite tests")
예제 #10
0
 def setUpClass(self):
     self.db_url = "postgresql://postgres@localhost/test"
     self.db = SQL(self.db_url)
     print("\nPOSTGRES tests")
예제 #11
0
 def setUpClass(self):
     self.db_url = "mysql://root@localhost/test"
     self.db = SQL(self.db_url)
     print("\nMySQL tests")