mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
CREATE INDEX statements on table page, closes #618
This commit is contained in:
parent
10b9d85eda
commit
28c4a6db5b
3 changed files with 46 additions and 1 deletions
|
|
@ -232,7 +232,18 @@ class Database:
|
|||
)
|
||||
if not table_definition_rows:
|
||||
return None
|
||||
return table_definition_rows[0][0]
|
||||
bits = [table_definition_rows[0][0] + ";"]
|
||||
# Add on any indexes
|
||||
index_rows = list(
|
||||
await self.ds.execute(
|
||||
self.name,
|
||||
"select sql from sqlite_master where tbl_name = :n and type='index' and sql is not null",
|
||||
{"n": table},
|
||||
)
|
||||
)
|
||||
for index_row in index_rows:
|
||||
bits.append(index_row[0] + ";")
|
||||
return "\n".join(bits)
|
||||
|
||||
async def get_view_definition(self, view):
|
||||
return await self.get_table_definition(view, "view")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue