I have table in Clickhouse, which contain Decimal64(8) field. When I try to run simple query to select it via sqlalchemy-clickhouse, code throws an error.
Here is a code
DB create and insert
CREATE TABLE sample_table
(
field1 Decimal64(8),
field2 Decimal64(8)
)
ENGINE = MergeTree()
ORDER BY field1
Python code for getting data
import sqlalchemy as sa
a = sa.create_engine('clickhouse://default:@localhost:8123/')
from sqlalchemy.orm import sessionmaker
DBSession = sessionmaker(bind=a)
dbSession = DBSession()
c = dbSession.execute('Select * from sample_table').fetchone()
print c
I think issue can be fixed by adding following in connector.py line 90
# 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])
I have table in Clickhouse, which contain Decimal64(8) field. When I try to run simple query to select it via sqlalchemy-clickhouse, code throws an error.
Here is a code DB create and insert
Python code for getting data
I think issue can be fixed by adding following in connector.py line 90