在clickhouse-client中执行SELECT * FROM test_table;时,我会得到N行,但在使用sqlalchemy的python代码执行engine.execute('SELECT * FROM test_table;')时,只有N-2行。
复制步骤:
中执行以下命令
CREATE TABLE test_table (id INTEGER, created Date) ENGINE = MergeTree(created, (id), 8192);
INSERT INTO test_table (id, created) VALUES (1, 11345678);
INSERT INTO test_table (id, created) VALUES (2, 12345678);
INSERT INTO test_table (id, created) VALUES (3, 13345678);
INSERT INTO test_table (id, created) VALUES (4, 14345678);
SELECT * FROM test_table;结果:
SELECT *
FROM test_table
┌─id─┬────created─┐
│ 4 │ 2106-02-07 │
└────┴────────────┘
┌─id─┬────created─┐
│ 3 │ 2084-08-20 │
└────┴────────────┘
┌─id─┬────created─┐
│ 2 │ 2038-03-15 │
└────┴────────────┘
┌─id─┬────created─┐
│ 1 │ 1991-10-08 │
└────┴────────────┘
4 rows in set. Elapsed: 0.004 sec. 好的,4行和预期的一样。
from sqlalchemy import create_engine
connection_string = 'clickhouse://default:@localhost/default'
engine = create_engine(connection_string)
result = list(engine.execute('SELECT * FROM test_table;'))
print(len(result))
print(result)结果:
2
[('4', '2106-02-07'), ('2', '2038-03-15')]绝对不像预期的那样。这是怎么回事?
炼金术版本: 1.3.11
clickhouse版本(服务器和客户端):19.17.4.11
发布于 2021-03-04 07:45:21
修改connection_string = 'clickhouse+native://default:@localhost/default'
参见:https://github.com/xzkostyan/clickhouse-sqlalchemy/issues/10
https://stackoverflow.com/questions/59105030
复制相似问题