复合主键django和timescaledb(postgresql)

问题描述 投票:0回答:1

我使用 django 作为我的后端,使用 postgresql 作为我的数据库,因为我有时间序列数据,我使用 timescaledb。我有称为设备的超表。字段created_datetime(timestamp) 和device_id(integer) 上有一个复合主键。我想使用 django 内置的日志记录用户活动( LogEntry 表),所以我应该有一个代表 hyper 表的模型。我怎样才能做到这一点? 我尝试了很多事情,比如创建一个模型,将created_datetime作为主键,然后在管理站点中我遇到错误ID“2024-05-06 11:55:21”不存在。难不成被删了?

django postgresql django-models timescaledb
1个回答
0
投票

devices
是跟踪设备数据样本的超级表吗?如果是,则需要与另一个字段构建主键组合。

https://docs.timescale.com/use-timescale/latest/hypertables/hypertables-and-unique-indexes/

© www.soinside.com 2019 - 2024. All rights reserved.