Show total number of rows in table

This commit is contained in:
Simon Willison 2017-10-24 17:11:36 -07:00
commit eef213ab4d
2 changed files with 4 additions and 1 deletions

3
app.py
View file

@ -195,10 +195,13 @@ class TableView(BaseView):
columns = [r[0] for r in rows.description]
pks = pks_for_table(conn, table)
rows = list(rows)
info = ensure_build_metadata()
total_rows = info[name]['tables'][table]
return {
'database': name,
'table': table,
'rows': rows,
'total_rows': total_rows,
'columns': columns,
'primary_keys': pks,
}, lambda: {

View file

@ -5,7 +5,7 @@
{% block content %}
<h1><a href="/{{ database }}-{{ database_hash }}">{{ database }}</a></h1>
<h2>{{ table }}</h2>
<h2>{{ table }} ({{ total_rows }} total row{% if total_rows == 1 %}{% else %}s{% endif %} in this table)</h2>
<style>
td {