How to add checkboxes to a Pandas Dataframe table using Flask?

Ale*_*nco 5 html python sqlite flask pandas

I am currently rendering an simple HTML table using Flask/Pandas Dataframe (to_html) using rows from a table in an SQLite3 DB.

How do I add checkboxes to the table?

After selections are made dump all the values from the Name column to a text file?

Example:

ID  Name    Manager 
1   server1 manager1
2   server2 manager2

Any help would be appreciated.

P.S. This is my first question on Stack overflow. If you need more information please let me know.

von*_*avl 0

我会在这里通过解决方法来完成。

  1. 在 template.html 中创建 html 组合框
  2. 使用routes.py中数据库中的值填充组合框
  3. 另外,在routes.py中读取组合框选定的值,并根据该值将sql请求更改为数据库 - 例如值1 - sql查询没有where条件,否则添加where条件名称=(in)选定的值
  4. 当您发送请求时,您可以在routes.py中选择是否想要具有不同数据的render_template,或者是否提交到另一个将数据导出到文本文件的路由(您可以留在pandas并使用to_csv)

此外,您的问题包含多个问题。最好能说得更具体一些。

如果您只想将复选框添加为表中的另一列,那么您可以通过 javascript 进行过滤,但通过 javascript 将选择传递给 Flask 路由是另一件更困难的事情。另外,我会选择不同的值而不是所有行值。