Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3226484
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:27:44+00:00 2026-05-17T16:27:44+00:00

I want to develop an application which uses Django as Fronted and Celery to

  • 0

I want to develop an application which uses Django as Fronted and Celery to do background stuff.
Now, sometimes Celery workers on different machines need database access to my django frontend machine (two different servers).
They need to know some realtime stuff and to run the django-app with

python manage.py celeryd 

they need access to a database with all models available.

Do I have to access my MySQL database through direct connection? Thus I have to allow user “my-django-app” access not only from localhost on my frontend machine but from my other worker server ips?

Is this the “right” way, or I’m missing something? Just thought it isn’t really safe (without ssl), but maybe that’s just the way it has to be.

Thanks for your responses!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:27:45+00:00Added an answer on May 17, 2026 at 4:27 pm

    They will need access to the database. That access will be through a database backend, which can be one that ships with Django or one from a third party.

    One thing I’ve done in my Django site’s settings.py is load database access info from a file in /etc. This way the access setup (database host, port, username, password) can be different for each machine, and sensitive info like the password isn’t in my project’s repository. You might want to restrict access to the workers in a similar manner, by making them connect with a different username.

    You could also pass in the database connection information, or even just a key or path to a configuration file, via environment variables, and handle it in settings.py.

    For example, here’s how I pull in my database configuration file:

    g = {}
    dbSetup = {}
    execfile(os.environ['DB_CONFIG'], g, dbSetup)
    if 'databases' in dbSetup:
        DATABASES = dbSetup['databases']
    else:
        DATABASES = {
            'default': {
                'ENGINE': 'django.db.backends.mysql',
                # ...
            }
        }
    

    Needless to say, you need to make sure that the file in DB_CONFIG is not accessible to any user besides the db admins and Django itself. The default case should refer Django to a developer’s own test database. There may also be a better solution using the ast module instead of execfile, but I haven’t researched it yet.

    Another thing I do is use separate users for DB admin tasks vs. everything else. In my manage.py, I added the following preamble:

    # Find a database configuration, if there is one, and set it in the environment.
    adminDBConfFile = '/etc/django/db_admin.py'
    dbConfFile = '/etc/django/db_regular.py'
    import sys
    import os
    def goodFile(path):
        return os.path.isfile(path) and os.access(path, os.R_OK)
    if len(sys.argv) >= 2 and sys.argv[1] in ["syncdb", "dbshell", "migrate"] \
        and goodFile(adminDBConfFile):
        os.environ['DB_CONFIG'] = adminDBConfFile
    elif goodFile(dbConfFile):
        os.environ['DB_CONFIG'] = dbConfFile
    

    Where the config in /etc/django/db_regular.py is for a user with access to only the Django database with SELECT, INSERT, UPDATE, and DELETE, and /etc/django/db_admin.py is for a user with these permissions plus CREATE, DROP, INDEX, ALTER, and LOCK TABLES. (The migrate command is from South.) This gives me some protection from Django code messing with my schema at runtime, and it limits the damage an SQL injection attack can cause (though you should still check and filter all user input).

    This isn’t a solution to your exact problem, but it might give you some ideas for ways to smarten up Django’s database access setup for your purposes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop a data-driven WPF application, which uses WCF to connect to
I am currently trying to develop an application which uses Skype API to call
I want to develop a windows application. If I use native C++ and MFC
I want to develop an iPhone application using the utility template, where the flip
I want to develop a mobile web application using asp.net 3.5 that can be
Imagine that you want to develop a non-trivial end-user desktop (not web) application in
I want to develop Java apps, real quick, what IDE should I choose?
I want to develop simple Serverless LAN Chat program just for fun. How can
I want to develop a very simple 2D game in Python. Pygame is the
I want to develop ASP.NET C# based MMOG (Massively multiplayer online game). I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.