Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
Changing Flask app's config variables during app runtime?

So I have a flask app running and this is how the config file looks like:

class config(object):
    SECRET_KEY = 'india'

class configTest(config):
   MYSQL_HOST = 'host1'
    MYSQL_PORT = 3306
    MYSQL_USER = 'admin'
    MYSQL_PASSWORD = 'yangmai'
    MYSQL_DB = 'ide'

class configProd(config):
    MYSQL_HOST = 'host2'
    MYSQL_PORT = 3306
    MYSQL_USER = 'admin'
    MYSQL_PASSWORD = 'yangmai'
    MYSQL_DB = 'ide'

In my init.py, I do this:

app.config.from_object('project.config.configTest')

Works good. Now what I want is to give user the option to switch the db at the time of logging in. So essentially, the config class should change from configTest to configProd or vice versa as the user selects.

The idea is to give user the option to access the test and prod environments without deploying two separate apps. Any solutions? Also, the app is run by apache.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!