Traceback (most recent call last):
File "sql-example.py", line 14, in <module>
datapackage_storage.export_package(storage, 'nasdaq-listings/datapackage.json', 'nasdaq-listings')
File "/home/vitor/datasets/venv/src/datapackage-storage/datapackage_storage/package.py", line 86, in export_package
schema = storage.describe(table)
File "/home/vitor/datasets/venv/src/jtssql/jtssql/storage.py", line 180, in describe
self.__prefix, table, dbtable.columns, dbtable.constraints)
File "/home/vitor/datasets/venv/src/jtssql/jtssql/helpers.py", line 113, in restore_schema
message = 'Type %s is not supported' % column.type
TypeError: Type TEXT is not supported
The problem is that SQLAlchemy has both sqlalchemy.sql.sqltypes.Text and sqlalchemy.sql.sqltypes.TEXT, and in our mapping at .restore_schema we only use the first one:
When we try to get mapping[column.type.__class__] afterwards, it isn't found and the exception is thrown.
I don't know why SQLAlchemy has both .Text and .TEXT (and others), or why one is used and not the other, but we should support both. Lucky for us, .TEXT inherits from .Text, so we can use that.
For example, I followed the
import_datapackage.py
at https://gist.github.com/vitorbaptista/19d476d99595584e9ad5 to import https://github.com/datasets/nasdaq-listings into a SQLite3 database. After that, I tried to export it back to a datapackage by using theexport_datapackage.py
file at the same gist. I then got the following traceback:The problem is that SQLAlchemy has both
sqlalchemy.sql.sqltypes.Text
andsqlalchemy.sql.sqltypes.TEXT
, and in our mapping at.restore_schema
we only use the first one:When we try to get
mapping[column.type.__class__]
afterwards, it isn't found and the exception is thrown.I don't know why SQLAlchemy has both
.Text
and.TEXT
(and others), or why one is used and not the other, but we should support both. Lucky for us,.TEXT
inherits from.Text
, so we can use that.