According to the Python API for DolphinDB (5.4.2), when uploading tables containing objects of Python decimal.Decimal()
, you must ensure that all values in the columns of DECIMAL type have the same decimal digits. Otherwise, it will return a value with the same digits as the first row of value. Your first row of data has four decimal digits, so error will occur when you upload data with 3 decimal digits.
To solve the problem, you can try the following script:
price_list = [Decimal(str(round(random.uniform(1, 1000),4))).quantize(decimal.Decimal("0.0000")) for _ in range(10)] + [Decimal(str(round(random.uniform(1, 100),4))).quantize(decimal.Decimal("0.0000")) for _ in range(10)]