def METHOD_NAME(self, layer, cols="*", where=None):
    """Select records from the table
    Return number of selected records, -1 on error
    """
    if layer <= 0:
        return -1
    nselected = 0
    table = self.layers[layer]["table"]  # get table desc
    # select values (only one record)
    if where is None or where == "":
        sql = "SELECT %s FROM %s" % (cols, table)
    else:
        sql = "SELECT %s FROM %s WHERE %s" % (cols, table, where)
    ret = RunCommand(
        "db.select",
        read=True,
        quiet=True,
        flags="v",
        sql=sql,
        database=self.layers[layer]["database"],
        driver=self.layers[layer]["driver"],
    )
    # self.tables[table][key][1] = str(cat)
    if ret:
        for line in ret.splitlines():
            name, value = line.split("|")
            # casting ...
            if value:
                if not isinstance("", self.tables[table][name]["ctype"]):
                    value = self.tables[table][name]["ctype"](value)
                else:
                    value = GetUnicodeValue(value)
            else:
                value = None
            self.tables[table][name]["values"].append(value)
            nselected = 1
    return nselected