X-Git-Url: https://git.jsancho.org/?p=datasette-pytables.git;a=blobdiff_plain;f=datasette_pytables%2F__init__.py;fp=datasette_pytables%2F__init__.py;h=9cb90051037c91770f7b10af62dc7ea21435e5e1;hp=c4087730d24699c52968cb34b1de0955635b24a0;hb=a408f0f468266f9b647e8572babda08fe9e0e09c;hpb=48833d5bdbb105a09731696e3dc293a2e68460cc diff --git a/datasette_pytables/__init__.py b/datasette_pytables/__init__.py index c408773..9cb9005 100644 --- a/datasette_pytables/__init__.py +++ b/datasette_pytables/__init__.py @@ -118,12 +118,16 @@ class PyTablesConnector(dc.Connector): start = 0 end = table.nrows - # Use 'where' statement or get all the rows - def _cast_param(field, pname): - # Cast value to the column type + def _get_field_type(field): coltype = table.dtype.name if type(table) is tables.table.Table: coltype = table.coltypes[field] + return coltype + + # Use 'where' statement or get all the rows + def _cast_param(field, pname): + # Cast value to the column type + coltype = _get_field_type(field) fcast = None if coltype == 'string': fcast = str @@ -266,7 +270,7 @@ class PyTablesConnector(dc.Connector): row['count(*)'] = int(table.nrows) elif field_name.get('json_type'): field_name = field_name.get('json_type') - row['json_type(' + field_name + ')'] = table.coltypes[field_name] + row['json_type(' + field_name + ')'] = _get_field_type(field) else: raise Exception("Function not recognized") else: