启动服务器后,Python烧瓶无法从mysql中获取数据库。

时间:2018-04-21 13:19:22

标签: python mysql flask

初始化代码

@app.route('/illegal/')
@login_required
def illegal():
    c.execute('SELECT * FROM image')
    datas = c.fetchall()


    return render_template('illegal.html', datas = datas)

illegal.html

<tbody>
        {% for data in datas %}
        <tr>
            <td style="width:17%">{{data[1]}}</td>
            <td style="width:17%">{{data[2]}}</td>
            <td style="width:17">{{data[3]}}</td>
            <td style="width:17%">{{data[4]}}</td>
            <td style="width:25%"><img src={{data[5]}} style=" max-width:     80%; height: auto" class="img-rounded" width="100" hegiht="100"      ></td>
        </tr>
        {% endfor %}

想象一下,Mysql中有4个数据,然后启动服务器。当我将新数据插入表格时。我的网站不知道有新的。它只知道启动服务器之前存在的原始版本。当我检查mysql时,插入了新数据。但现在存在于Web服务器中。如果您知道解决方案,请帮助我

0 个答案:

没有答案