From: Javier Sancho Date: Tue, 15 May 2018 10:27:51 +0000 (+0200) Subject: Provide int types instead numpy types for allowing JSON encoding X-Git-Url: https://git.jsancho.org/?p=datasette-pytables.git;a=commitdiff_plain;h=ab2cd56eb3c5b15410fecdc19e037ff3b6ff6a63;hp=1d4a2abc6556f51a94b28f1e06cd682be961a7ea Provide int types instead numpy types for allowing JSON encoding --- diff --git a/datasette_pytables/__init__.py b/datasette_pytables/__init__.py index 217214f..0bbb25f 100644 --- a/datasette_pytables/__init__.py +++ b/datasette_pytables/__init__.py @@ -19,7 +19,7 @@ def inspect(path): 'name': table._v_pathname, 'columns': colnames, 'primary_keys': [], - 'count': table.nrows, + 'count': int(table.nrows), 'label_column': None, 'hidden': False, 'fts_table': None, @@ -120,13 +120,13 @@ class Connection: # Prepare rows if len(fields) == 1 and fields[0] == 'count(*)': - rows.append(Row({fields[0]: table.nrows})) + rows.append(Row({fields[0]: int(table.nrows)})) else: for table_row in table_rows: row = Row() for field in fields: if field == 'rowid': - row[field] = table_row.nrow + row[field] = int(table_row.nrow) elif field == '*': for col in table.colnames: value = table_row[col]