def hatebu(): # データベースアクセス path = os.path.dirname(os.path.dirname( os.path.abspath(__file__))) + "/db" connect = sqlite3.connect(path + "/hatena.db") cursor = connect.cursor() # hatebu_list テーブルからデータを取得 sql = """ SELECT * FROM hatebu_list """ # 取得したデータをパースしてリストに保存 hatebu_list = [] con = cursor.execute(sql) for row in con: tmp_row = {} for idx, col in enumerate(cursor.description): tmp_row[col[0]] = row[idx] hatebu_list.append(tmp_row) connect.close() # Slackのチャンネル一覧を取得 slack = Slack("SlackのToken") channel_list = slack.get_channnel_list() return template('hatebu', hatebu_list=hatebu_list, channel_list=channel_list)