Skip to content

transaction.atomic() problem with DATABASE_ROUTERS #182

@asr-systify

Description

@asr-systify

Hi,

I use this library in a project with DATABASE_ROUTERS.
As soon as django_apscheduler is not in the 'default' database, I get the following error message:
"select_for_update cannot be used outside of a transaction".

with transaction.atomic():

Which in my opinion is also conclusive, because atomic points to the 'default' db without parameters.
The following sample change fixes my problem:

DATABASE_APPS_MAPPING = {
'django_apscheduler': 'test',
}

with transaction.atomic(using='test'):

Is there another approach to this problem case? I couldn't find any other solution when django_apscheduler is not in my 'default' db.

version:
Django==3.2.9
django-apscheduler==0.6.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions