将 SQLite3 数据库中的查询显示到 Bootstrap table

Display Query from SQLite3 Database into Bootstrap table

我想将 SQLite3 中的查询显示到 Bootstrap Table。但它似乎不起作用并且不会显示 table。 附上我的代码

views.py

@main.route('/currentlist', methods=["GET"])
def current():
    if request.method == 'GET':
        Connection = sqlite3.connect('C:\Backup_old\Task\e_ticket\my_app\db\customer.db')
        cursor = Connection.cursor()
        query2 = "SELECT * from customer"
        cursor.execute(query2)
        test = cursor.fetchall()
        return render_template('overview.html', testform = test)

HTML

<div class= "content">

      <table id="dtBasicExample" class="table" width="100%">
        <thead>
          <tr>
            <th class="th-sm">Date
            </th>
            <th class="th-sm">time
            <th class="th-sm">customer
            </th>
            <th class="th-sm">pic
            </th>
            <th class="th-sm">category
            </th>
            <th class="th-sm">description
            </th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>9 December 2021</td>
            <td>15:30:00</td>
            <td>AB Corp.</td>
            <td>Bob</td>
            <td>network</td>
            <td>network is down</td>
          </tr>
          <tr>
            <td>9 December 2021</td>
            <td>17:30:00</td>
            <td>AB Corp.</td>
            <td>Alex</td>
            <td>computer</td>
            <td>computer is broken</td>
          </tr>
          <tr>
            <td>10 December 2021</td>
            <td>05:32:00</td>
            <td>CD Corp.</td>
            <td>Bob</td>
            <td>Server</td>
            <td>server is down</td>
          </tr>
          <tr>
            <td>12 December 2021</td>
            <td>10:30:00</td>
            <td>AB Corp.</td>
            <td>Bob</td>
            <td>printer</td>
            <td>printer is down</td>
          </tr>


        </tbody>
        
      </table>
    



    </div>

它应该是这样的,但是来自数据库的数据 enter image description here

我读过很多类似的问题,但大多数都使用 SQLAlchemy。

非常感谢任何帮助!

您需要对数据使用循环和模板变量。

<tbody>
  {% for row in testform %}
  <tr>
    <td>{{ row[0] }}</td>
    <td>{{ row[1] }}</td>
    <td>{{ row[2] }}</td>
    <td>{{ row[3] }}</td>
    <td>{{ row[4] }}</td>
    <td>{{ row[5] }}</td>
  </tr>
  {% endfor %}
</tbody>