简体   繁体   English

连接 Django Celery 节拍到正确的数据库

[英]Connecting Django Celery Beat to the correct database

I am getting started with celery (4.4.7) using this tutorial .我正在使用本教程开始使用 celery (4.4.7)。 I believe I have set up everything correctly but whenever I run the following command:我相信我已经正确设置了所有内容,但是每当我运行以下命令时:

celery -A myproj beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler

I get the error:我得到错误:

django.db.utils ProgrammingError :relation "django_celery_beat_periodictask" does not exist

I migrated the DB and so the celery beat tables do exist.我迁移了数据库,因此确实存在 celery 节拍表。 This closed issue https://github.com/celery/django-celery-results/issues/22 is exactly the error I am getting, however, what seems to be the solution does not work for me possibly because I don't know how to do it.这个已关闭的问题https://github.com/celery/django-celery-results/issues/22正是我得到的错误,但是,似乎解决方案对我不起作用可能是因为我不知道怎么做。

I would check your settings.py file to check what you have set for the celery config.我会检查您的 settings.py 文件以检查您为 celery 配置设置的内容。

If this has not been created with postgres then you can use postgres to create the db, user, password and set privledges如果这不是用 postgres 创建的,那么您可以使用 postgres 创建数据库、用户、密码并设置权限

Creating user创建用户

$ sudo -u postgres createuser <username>

Creating Database创建数据库

$ sudo -u postgres createdb <dbname>

Giving the user a password给用户一个密码

$ sudo -u postgres psql
psql=# alter user <username> with encrypted password '<password>';

Granting privileges on database授予数据库权限

psql=# grant all privileges on database <dbname> to <username> ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM