Example #1
0
    def add_list_from_database():
        C = WordMatchResponse
        C.List = []

        cols = [Command.COL_ID]
        cols.extend(Command.COLS)
        cols.extend(C.COLS)
        cols.extend(User.COLS)
        cols.extend(Chat.COLS)

        tables = [C.TABLE, Command.TABLE, User.TABLE, Chat.TABLE]
        equals = [(C.COL_ID, Command.COL_ID),
                  (User.COL_ID, Command.COL_USER_ID),
                  (Chat.COL_ID, Command.COL_CHAT_ID),
                  (Command.COL_BOT_NAME, '\'' + Constants.APP_NAME + '\'')]

        r = Database.select(cols, tables, equals)

        success, rows = Database.get_rows(r, -1)

        if success:
            for row in rows:
                cls = WordMatchResponse.from_database(row)
                if cls is not None:
                    C.List.append(cls)

        return True
Example #2
0
def load_chats():
    cols = [Chat.COL_ID]
    cols.extend(Chat.COLS)
    data = Database.select(cols, [Chat.TABLE])
    [result, rows] = Database.get_rows(data, 0)
    if result:
        for row in rows:
            chats.append(Chat.from_database(row))