diff --git a/connector.py b/connector.py index 5ae983d..4733d26 100644 --- a/connector.py +++ b/connector.py @@ -84,18 +84,27 @@ def create_ad_hoc_field(cls, db_type): if db_type == 'LowCardinality(String)': db_type = 'String' + if db_type == 'Bool': + db_type = 'UInt8' + + if db_type == 'LowCardinality(Nullable(String))': + db_type = 'String' + + if db_type == 'Map(String, UInt64)': + db_type = 'String' + if db_type.startswith('DateTime'): db_type = 'DateTime' if db_type.startswith('Nullable'): inner_field = cls.create_ad_hoc_field(db_type[9 : -1]) return orm_fields.NullableField(inner_field) - + # db_type for Deimal comes like 'Decimal(P, S) string where P is precision and S is scale' if db_type.startswith('Decimal'): nums = [int(n) for n in db_type[8:-1].split(',')] return orm_fields.DecimalField(nums[0], nums[1]) - + # Simple fields name = db_type + 'Field' if not hasattr(orm_fields, name): diff --git a/setup.py b/setup.py index 9ccecf5..c0f204e 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,16 @@ VERSION = [0, 1, 5] readme = open('README.rst').read() +dialects = [ + 'clickhouse{}=sqlalchemy_clickhouse.{}'.format(driver, d_path) + + for driver, d_path in [ + ('', 'base:ClickHouseDialect'), + ('.http', 'base:ClickHouseDialect'), + ('.native', 'base:ClickHouseDialect') + ] +] + setup( name='sqlalchemy-clickhouse', version='.'.join('%d' % v for v in VERSION[0:3]), @@ -32,9 +42,7 @@ 'sqlalchemy_clickhouse': ['LICENSE.txt'], }, entry_points={ - 'sqlalchemy.dialects': [ - 'clickhouse=sqlalchemy_clickhouse.base', - ] + 'sqlalchemy.dialects': dialects }, classifiers = [ 'Development Status :: 5 - Production/Stable',