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)
Here I am dumping my database(olddb).Is the syntax is correct or not for dumping or not? I am running a command as "python manage.py sqldump". I have a schema in my current DB.How to migrate the data to a new database? I don't have any idea what is the schema present in new DB. While migrating data if error comes the rollback have to be done in new DB.
Or any other good Article to get more INFO?