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

  • SEARCH
  • Home
  • 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 9185527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:17:57+00:00 2026-06-17T19:17:57+00:00

I have this in my main execution file: databaseUrl = appPath + ‘/db/timey.db’ which

  • 0

I have this in my main execution file:

databaseUrl = appPath + '/db/timey.db' 

which is pointing to my SQLite DB.

I have done some encapsulation for accessing my model (Data/DB). So until databaseURL finally gets used I would need to pass it from main -> view.py -> model.py -> db.py.
This would be stupid because e.g. my view class doesn’t need to know about my database or its path. So what would be a proper approach to actually make this path “globally” accessable without passing it around all the time?

I tried to make databaseUrl global, but I don’t like the idea and haven’t really gotten it to work like that anyway.

Storing the information in an external file would be an overkill, as it is the only (constant!) global used variable anyway.

Thank you!

  • 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-06-17T19:17:58+00:00Added an answer on June 17, 2026 at 7:17 pm

    I don’t think storing it in an external file would be overkill at all. I think it is helpful to have a settings or config file

    # settings.py
    
    import os
    PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
    DATABASE_URL = ''
    DATABASE_USER = ''
    DATABSE_PASSWORD = ''
    

    etc.

    from myproject import settings 
    settings.DATABASE_URL
    

    This is what django and scrapy do to store a projects database config settings, and all other project settings

    Also, if you have a database class it might make sense to store these settings inside of it? I don’t know.

    The settings.py file let you easily set up a development / local database urls.
    TO do this you can have a local_settings.py file that will never be put under version control or packaged in your project

    in your settings.py file

    try:
      from local_settings import *
    except ImportError:
      pass
    

    then in local_settings.py you can override the DATABASE_URL to be your dev database!! This is a django project convention

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

Sidebar

Related Questions

On my main page I have this jquery code which does an ajax call
In the main view i have this function public function lang($file, $language){ require 'languages/'.$language.'/'.
i have this hap code of which tries to selects sub-node from the main
I have a text file with some content. I need to search this content
I have the following scenario: Main page Nested page Common JS file (which is
In the below shown html i have this main div as cxfeeditem feeditem and
I have this TreeView: Main Node Header=Main Sub Node Header=Sub1 Final Node Header=Item1 Final
I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
I have this in my main.m: printf(make autorelease pool \n); NSAutoreleasePool * pool =
I have this declared on my main class: [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@atlas.plist]; CCSpriteBatchNode *batchNode =

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.