I am able to show the all the tablenames and their respective columns as:
SNO Tables in Database Column names
1 table1 a
2 table1 b
3 table2 c
4 table2 d
for which html file is:
<html>
<head><link rel="stylesheet" href="{{ url_for('static', filename='css/index.css') }}"></head>
<body>
<div>
<table border="1" align="center" class="w3-table w3-striped">
<caption><strong>Farm Automation Details</strong></caption>
<thead>
<tr>
<th>SNO</th>
<th style="text-align:center">Tables in Database</th>
<th style="text-align:center">Column names</th>
</tr>
</thead>
<tbody>
{%for row in result%}
<tr>
<td></td>
<td style="text-align:center">{{ row[0] }}</td>
<td style="text-align:center">{{ row[1] }} </td>
</tr>
{%endfor%}
</table>
</div>
</body>
</html>
and to fetch table and column names i wrote:
sql="select table_name,column_name from information_schema.columns where table_schema = 'farmautomation' order by table_name,ordinal_position"
cursor.execute(sql)
result = cursor.fetchall()
I am expecting to show the table as:
SNO Tables in Database Column names
1 table1 a,b
2 table2 c,d
I tried to groupby on table_name,but it didn't work, May I know how can I show as above ? How to show the table name once and show all column names of respective table ?