Example #1
0
 def test2(self):
     db = SqlDb(DB_URI)
     
     # test locking and re-opening
     cur = db.cursor()
     cur.close()
     cur = db.cursor()
     cur.close()
Example #2
0
 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()
Example #3
0
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()
Example #4
0
 def test1(self):
     
     db = SqlDb("mysql://root@non-existing-host/kvsql")
     
     with self.assertRaises(DatabaseError):
         db.cursor()