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 6158797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:01:19+00:00 2026-05-23T21:01:19+00:00

I have a django application which talks to a database to which several other

  • 0

I have a django application which talks to a database to which several other applications of mine talk to. When the application starts it reads different tables in different databases and uses it to determine which connection to use for which table.

Is it a good practice or bad practice to allow an application to read all table names in
such a manner?

following is the excerpt from my routers.py :

db1_tables = connections['db1'].introspection.table_names()      
default_db_tables = connections['default'].introspection.table_names()      
db3_tables = connections['db3'].introspection.table_names()

class MyAppRouter(object):
    def db_for_read(self, model, **hints):
        if model._meta.db_table in db1_tables :
            return 'db1'
        if model._meta.db_table in default_db_tables:
            return 'default'
        if model._meta.db_table in db3_tables:
            return 'db3'
        return 'default'

    def db_for_write(self, model, **hints):
        return self.db_for_read(model,**hints)

    def allow_syncdb(self, db, model):
        return False

Can anyone highlight the pros and cons for this approach? One advantage I see with this approach is that I do not have to maintain a list of table names in each database that I am using. One possible disadvantage is that I am reading even the names of those tables which my application does not have access to.

  • 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-23T21:01:20+00:00Added an answer on May 23, 2026 at 9:01 pm

    I don’t see a problem with this approach if the other tables don’t contain sensitive information. I.e., I would generalize the situation like so: If you have an app that connects to a database but doesn’t use all the tables of that database, and the knowledge that those tables exist is itself a security issue — then those tables shouldn’t be in that database.

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

Sidebar

Related Questions

I have a Django application which edits a database table, which another application polls
I have a Django application which allows different kinds of users: firms, administrators, external
I have a Django application which sometimes needs to send some data through TCP
I have a view my Django application which when invoked calls my backend. My
I have the following Django Model which retrieves 3 records from a database. The
I have a a django application which is being served from apache/mod_wsgi under www.mysite.com/mysite
I want to have RSS feeds in my Django application, which should be viewable
In a django application I have the following model: class Appointment(models.Model): #some other fields
I have a Django application which includes a custom model field (and accompanying form
I have a django application which has one main table/model which references various 'lookup'

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.