Skip to content

Specify which database backend to use #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RealOrangeOne opened this issue Jun 8, 2024 · 7 comments
Open

Specify which database backend to use #38

RealOrangeOne opened this issue Jun 8, 2024 · 7 comments
Labels
database-backend Issues relating to the database backend
Milestone

Comments

@RealOrangeOne
Copy link
Owner

It's currently not possible to specify which database backend will be used (ie the ones configured in DATABASES). Especially for SQLite, it's useful to separate the queue tables into a separate database.

@RealOrangeOne RealOrangeOne added the database-backend Issues relating to the database backend label Jun 8, 2024
@RealOrangeOne RealOrangeOne added this to the 2.0 milestone Jun 8, 2024
@turingnixstyx
Copy link

Hey is this still open and unassigned?

@RealOrangeOne
Copy link
Owner Author

Yes. If you're interested in working on it, by all means do. I don't assign issues to people specifically though - anyone can work on anything.

@fazeelghafoor
Copy link

@RealOrangeOne if this needs to be implemented, can we just add database in the following tasks config if we are using DatabaseBackend and set the default to default database defined in settings and then have all task related models to use the database defined in tasks config dict.

TASKS = {
    "default": {
        "BACKEND": "django_tasks.backends.immediate.ImmediateBackend",
        "DATABASE": "name_of_the_database" i.e. "tasks_db" # if not set use the default
    }
}

or are we looking for a more sophisticated solution than this option.

@RealOrangeOne
Copy link
Owner Author

I think it'll need something a little more complex than this, as both the worker and migrations need to use this value. It might be that a database router is the only way to implement this, in which case there's not much to do ourselves besides ensure the correct DB is specified when needed.

@hartungstenio
Copy link

Since it's something specific to the DatabaseBackend, it feels like it should reside inside an OPTIONS key:

TASKS = {
    "default": {
        "BACKEND": "django_tasks.backends.database.DatabaseBackend",
        "OPTIONS": {
            "alias": "tasks_db"
        }
}

@RealOrangeOne
Copy link
Owner Author

I think a better way to handle this would be using a database router. I don't think one should be included, but at least documenting how to write one would be ideal. Exactly how multiple installed database backends would be handled I don't know.

@grandimam
Copy link

Hi @RealOrangeOne , I have created a draft PR that attemps to solve the problem based on the above suggestions. Any suggestions would be helpful - #122.

@RealOrangeOne RealOrangeOne modified the milestones: 2.0, 1.0 Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database-backend Issues relating to the database backend
Projects
None yet
Development

No branches or pull requests

5 participants