def test2(self): db = SqlDb(DB_URI) # test locking and re-opening cur = db.cursor() cur.close() cur = db.cursor() cur.close()
def test4(self): db = SqlDb(DB_URI) # testl locking when query failes cur = db.cursor() with self.assertRaises(Exception): cur.execute("SQL with wrong syntax") cur.close() cur = db.cursor() cur.close()
def clean_db(): db = SqlDb(DB_URI) cur = db.cursor() q = """ SHOW TABLES """ cur.execute(q) for row in cur.fetchall(): table_name = row[0] cur.execute("""DROP TABLE %s""" % table_name) cur.close()
def test1(self): db = SqlDb("mysql://root@non-existing-host/kvsql") with self.assertRaises(DatabaseError): db.cursor()