0

in particular, I succeeded with a row of objects but, as sometimes the object searched has multiple answer lines (unknown number) I would like them to be added to the table.

         if 'CODART'  in request.form:
           CODART = request.form['CODART']
           cursor = conn.cursor()
           cursor.execute('SELECT .... MSI_CODART =?',(CODART))
           codart = cursor.fetchone()
           codart1=codart[i]
           print(codart[i])```

I use this code repeated by changing column name
then I pass them to html:

       ``` codart1 is not None:
         return render_template('Simple.html', codart2=codart1)```
  • [1] Render the top part of the table (e.g.,``, `
    `, etc.). [2] Loop through the rows returned by `.fetchall()` and append a table row for each row in the resultset. [3] Render the remaining HTML to finish the table (e.g.,`
    `)
    – Gord Thompson Jul 15 '21 at 12:37
  • @GordThompson 6.5 years later - is this still the best way? I tried pd.to_html() but having to use the styler for every column is not fun and creates terrible HTML. – beneM Dec 29 '21 at 22:16
  • @beneM - [This](https://stackoverflow.com/q/50807744/2144390) might prove helpful. – Gord Thompson Dec 29 '21 at 22:39

0 Answers0