Situation
--Purpose of python+sql+html--
python: Connection between database and a website
sql: manage the database
html: display the result from database
--What i have done--
sql(done): create a function to return a table like this
CREATE OR REPLACE FUNCTION name RETURNS TABLE ( parameters )
AS
$$
SELECT * from table;
$$
LANGUAGE SQL;
python: receive the result and format it correctly
print the result in python
result: ['(a,b,c,d,e,f,g,h)']
HTML: When i display this on my website,
Real life:
Table column 1 ((a,b,c,d,e,f,g,h)) |column 2 |column 3 |column 4 |column 5 |column 6 |column 7 |column 8
Expected:
Table column 1 (a) |column 2 (b) |column 3 (c)|column 4 (d)|column 5 (e)|column 6 (f) |column 7 (g)|column 8(h)
<table border = "1">
<tr>
<th>a</th><th>b</th><th>c</th><th>d</th>
<th>e</th><th>f</th><th>g</th><th>h</th>
</tr>
{% for row in rows %}
<tr>
{% for item in row%}
<td>
{{item}}
</td>
{% endfor%}
</tr>
{% endfor%}
</table>
what can i do to separate it to get what i expected?
Aucun commentaire:
Enregistrer un commentaire