示例#1
0
    def delete(cls, where=None, params=None):
        sql = 'DELETE FROM `%s`' % cls._tbl
        if not where:
            return db.update(sql)

        sql += ' WHERE ' + where
        return db.update(sql, params)
示例#2
0
    def delete(cls, where=None, params=None):
        sql = 'DELETE FROM `%s`' % cls._tbl
        if not where:
            return db.update(sql)

        sql += ' WHERE ' + where
        return db.update(sql, params)
示例#3
0
    def bind_host_id(cls, group_id, host_id):
        if not Host.get(host_id):
            return 'no such host_id'

        if cls.exists('grp_id = %s and host_id = %s', [group_id, host_id]):
            return 'already existent'

        if db.update('insert into grp_host(grp_id, host_id) values(%s, %s)', [group_id, host_id]) <= 0:
            return 'failure'

        return ''
示例#4
0
    def bind_host_id(cls, group_id, host_id):
        if not Host.get(host_id):
            return 'no such host_id'

        if cls.exists('grp_id = %s and host_id = %s', [group_id, host_id]):
            return 'already existent'

        if db.update('insert into grp_host(grp_id, host_id) values(%s, %s)',
                     [group_id, host_id]) <= 0:
            return 'failure'

        return ''
示例#5
0
    def bind(cls, group_id, hostname):
        h = Host.read('hostname = %s', [hostname])
        if not h:
            return 'no such host'

        if cls.exists('grp_id = %s and host_id = %s', [group_id, h.id]):
            return 'already existent'

        if db.update('insert into grp_host(grp_id, host_id) values(%s, %s)', [group_id, h.id]) <= 0:
            return 'failure'

        return ''
示例#6
0
    def bind(cls, group_id, hostname):
        h = Host.read('hostname = %s', [hostname])
        if not h:
            Host.create(hostname)
            h = Host.read('hostname = %s', [hostname])
            if not h:
                return 'host auto add failed'

        if cls.exists('grp_id = %s and host_id = %s', [group_id, h.id]):
            return 'already existent'

        if db.update('insert into grp_host(grp_id, host_id) values(%s, %s)',
                     [group_id, h.id]) <= 0:
            return 'failure'

        return ''
示例#7
0
 def update(cls, clause=None, params=None):
     sql = 'UPDATE `%s` SET %s' % (cls._tbl, clause)
     return db.update(sql, params)
示例#8
0
 def delete_one(cls, pk=None):
     sql = 'DELETE FROM `%s` WHERE %s = %%s' % (cls._tbl, cls._id)
     return db.update(sql, [pk])
示例#9
0
 def update(cls, clause=None, params=None):
     sql = 'UPDATE `%s` SET %s' % (cls._tbl, clause)
     return db.update(sql, params)
示例#10
0
 def delete_one(cls, pk=None):
     sql = 'DELETE FROM `%s` WHERE %s = %%s' % (cls._tbl, cls._id)
     return db.update(sql, [pk])