Example #1
0
    def testGenerate(self):
        db = generate(self.db, self.db_connect)
        self.assert_(hasattr(db, "Postal"))
        self.assert_(hasattr(db, "Municipal"))
        self.assert_(hasattr(db, "County"))

        svg = db.Postal(postal_no=4001)
        self.assertEqual(svg.postal_name, "STAVANGER")

        db.query_one("SELECT 1+1")
        db.query("SELECT * FROM postal")
        db.execute("DELETE FROM postal WHERE postal_no=9999")
        db.db.cursor()
Example #2
0
    def loadService(self, type, subtype, name, db):
        """Loads given service from data base

        Args:
            type - service type
            subtype - service subtype
            name - service name
            db - mysql database cursor

        All three parameters are necessary because only full path is guaranteed
        to be unique.
        """

        srv = getClass(type, subtype)
        if not srv:
            raise ScalakError("No such service registered: {0},{1}"
                    .format(type, subtype))
        srv = srv()

        res = db.execute('select field, value from services where project=%s and\
                type=%s and subtype=%s and name=%s',
                (self.id, type, subtype, name))
        tmp = []
        if res:
            tmp = db.fetchall()
            srv.load(self, name, tmp)
        self.addService(srv, True)