重写Postgres的芹菜结果表(芹菜\u taskmeta)

2024-10-05 14:24:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用芹菜来执行一些分布式任务,并希望覆盖celery_taskmeta并添加更多的列。我使用Postgres作为DB,SQLAlchemy作为ORM。我查了芹菜的资料,但找不到怎么做。你知道吗

我们将不胜感激。你知道吗


Tags: dbsqlalchemyorm分布式postgrescelery芹菜资料
2条回答

遵循文件:

database_table_names Default: {} (empty mapping).

When SQLAlchemy is configured as the result backend, Celery automatically creates two tables to store result meta-data for tasks. This setting allows you to customize the table names:

use custom table names for the database result backend.

database_table_names = {
     'task': 'myapp_taskmeta',
     'group': 'myapp_groupmeta'
 }

http://docs.celeryproject.org/en/latest/userguide/configuration.html#database-table-names

我建议采用另一种方法—添加一个包含扩展数据的额外表。这个表将有一个外键约束,确保每个记录都与celery_taskmeta中的特定条目相关。为什么采用这种方法?-它将您的域(应用程序的域)与芹菜域分开。而且它不涉及修改可能(理论上不应该)引起麻烦的表结构。你知道吗

相关问题 更多 >