table.count property, plus made a start on table documentation

This commit is contained in:
Simon Willison 2018-07-30 20:24:35 -07:00
commit b69f8b6c85
4 changed files with 80 additions and 1 deletions

View file

@ -71,6 +71,12 @@ class Table:
self.name = name
self.exists = self.name in self.db.tables
@property
def count(self):
return self.db.conn.execute(
"select count(*) from [{}]".format(self.name)
).fetchone()[0]
@property
def columns(self):
if not self.exists: