我在使用使用TimescaleDB创建连续聚合时遇到了错误,该错误涉及PostgreSQL materialized views:
connection = psycopg2.connect(DATABASE_URI)
cursor = connection.cursor()
cursor.execute(
"""CREATE MATERIALIZED VIEW quotes_1h WITH
(timescaledb.continuous)
AS
SELECT ticker, time_bucket('1h', time) as hour,
min(close) as low,
max(close) as high,
first(close, time) as open,
last(close, time) as close
FROM quotes
GROUP BY
ticker, time_bucket('1h', time);""")
connection.commit()
错误信息: psycopg2.errors.ActiveSqlTransaction: CREATE MATERIALIZED VIEW ... WITH DATA不能在事务块内运行
我已经开启了自动提交,但并没有起作用。
CREATE MATERIALIZED VIEW quotes_1h WITH
。 - Adrian Klaver