frictionlessdata / tableschema-sql-py

Generate SQL tables, load and extract data, based on JSON Table Schema descriptors.
MIT License
61 stars 19 forks source link

Express mapping in an external JSON to reuse as standard reference #73

Closed ppKrauss closed 7 years ago

ppKrauss commented 7 years ago

Hi, I am looking for a PHP implementation, so we perhaps use tableshema-py as reference algorithm for tableschema-php issue 35... The core seems the mapping and can be expressed as JSON to reuse into other contexts.

        mapping = {
            'any': sa.Text,
            'array': None,
            'boolean': sa.Boolean,
            'date': sa.Date,
            'datetime': sa.DateTime,
            'duration': None,
            'geojson': None,
            'geopoint': None,
            'integer': sa.Integer,
            'number': sa.Float,
            'object': None,
            'string': sa.Text,
            'time': sa.Time,
            'year': sa.Integer,
            'yearmonth': None,
        }

The suggestion: express in a external file, or generate code from a CSV with all datatype map descriptions... As "RosettaStone-tabular-datatypes" ;-)


PS: for more general translation of primitive data types, a CSV at Data Packaged Core Datasets with all datatypes, perhaps we can reuse from a

Canonic Description JSON SQL-92 Python Java ...
JSON UTF8 string string text str String ...
SQL-92 integer 4 bytes number int4 ... .... ....
.... .... ... .... .... .... ...
roll commented 7 years ago

@ppKrauss Thanks for the idea. But this mapping is tightly tied to sqlalchemy Python library. It also use some Postgres special case types later in the code etc. So it's not even a static mapping. I think there are almost no chances to re-use it across different platforms. Also it's very small and changing very rarely.

So my recommendation is just to translate it as a starting point to a PHP database library. It will be much more flexible for both sides.