X-Git-Url: https://git.jsancho.org/?p=datasette-pytables.git;a=blobdiff_plain;f=datasette_pytables%2F__init__.py;h=93f9b89cfa0577b9d4b10215cec6b191c595c3d3;hp=7bbc7c14063b5a562cb080c72609ccdf062fc9b2;hb=8d58881ab27b2acfc1f08f4108f8b4ac443b0204;hpb=b1fff4628f94a3f3eab70f5fcc1e5005679ef1d0 diff --git a/datasette_pytables/__init__.py b/datasette_pytables/__init__.py index 7bbc7c1..93f9b89 100644 --- a/datasette_pytables/__init__.py +++ b/datasette_pytables/__init__.py @@ -240,14 +240,18 @@ class Connection: elif sql == 'select sql from sqlite_master where name = :n and type="table"': try: table = self.h5file.get_node(params['n']) + colnames = ['value'] + if type(table) is tables.table.Table: + colnames = table.colnames row = Row() - row['sql'] = 'CREATE TABLE {} ()'.format(params['n']) + row['sql'] = 'CREATE TABLE {} ({})'.format(params['n'], ", ".join(colnames)) return [row] except: return [] else: raise Exception("SQLite queries cannot be executed with this connector") + class Row(list): def __init__(self, values=None): self.labels = []