From d3ebe73db6b25569b800ccd55ad8eb90dd88b773 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 30 May 2018 12:13:30 +0200 Subject: [PATCH] Show field names in create sql --- datasette_pytables/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/datasette_pytables/__init__.py b/datasette_pytables/__init__.py index 7bbc7c1..58fee10 100644 --- a/datasette_pytables/__init__.py +++ b/datasette_pytables/__init__.py @@ -240,8 +240,11 @@ 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 [] -- 2.39.5