阅读背景:

使用django管理命令转储数据库并迁移到新数据库

来源:互联网 
class Command(BaseCommand):
  args = 'Arguments is not needed'
  help = 'Django admin custom command poc.'

  def handle(self, *args, **options):
        db_alias = options.get('olddb') 
        db_entry = settings.DATABASES.get(db_alias)
        output = open(output_filename,'w')

        cmd = ["mysqldump",
               "-u", db_entry.get('USER'),
               "-p%s" % db_entry.get('PASSWORD'),
               "-h", db_entry.get('HOST'),
               db_entry.get('NAME')]
        subprocess.call(cmd, stdout=output)
class Command(BaseCommand):
  args = 'Arguments



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: