db.view_exists() method, needed by #1896

This commit is contained in:
Simon Willison 2022-11-18 14:16:38 -08:00
commit c588a89f26
3 changed files with 22 additions and 0 deletions

View file

@ -338,6 +338,12 @@ class Database:
)
return bool(results.rows)
async def view_exists(self, table):
results = await self.execute(
"select 1 from sqlite_master where type='view' and name=?", params=(table,)
)
return bool(results.rows)
async def table_names(self):
results = await self.execute(
"select name from sqlite_master where type='table'"