mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Cleaned up view_definition/table_definition code in table view
Also moved those out of standard JSON into just the HTML template context
This commit is contained in:
parent
7e0caa1e62
commit
0c22fa8f09
2 changed files with 21 additions and 33 deletions
|
|
@ -171,6 +171,21 @@ class Datasette:
|
|||
if query:
|
||||
return {"name": query_name, "sql": query}
|
||||
|
||||
async def get_table_definition(self, database_name, table, type_="table"):
|
||||
table_definition_rows = list(
|
||||
await self.execute(
|
||||
database_name,
|
||||
'select sql from sqlite_master where name = :n and type=:t',
|
||||
{"n": table, "t": type_},
|
||||
)
|
||||
)
|
||||
if not table_definition_rows:
|
||||
return None
|
||||
return table_definition_rows[0][0]
|
||||
|
||||
def get_view_definition(self, database_name, view):
|
||||
return self.get_table_definition(database_name, view, 'view')
|
||||
|
||||
def asset_urls(self, key):
|
||||
# Flatten list-of-lists from plugins:
|
||||
seen_urls = set()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue