0

i followed this solution to run customer django command programmatically , but it is limited for just one database connection. I have django app configured with multiple database , is it possible to run custom django command using specific database connection? exactly like when we use connections["DB_NAME_CONNECTION"].cursor() to execute an sql query thanks a lot for your help!

1 Answers1

1

One option is to create a new settings module (here's a guide) that contains your specific database connection configuration, and then use that settings module when using call_command():

management.call_command('mycommand', '--settings=mysite.settings.specificconnection')
DJ Ramones
  • 823
  • 1
  • 5
  • 11