'Get an entry id and add if not present.'

def get_id(self, imname):

    cur = self.con.execute(("select    rowid    from    imlist    where    filename='%s'" % imname))
    res = cur.fetchone()
    if (res == None):
        cur = self.con.execute(("insert    into    imlist(filename)    values    ('%s')" % imname))
        return cur.lastrowid
    else:
        return res[0]
