Maybe you use dumpdata in json and then modify the table name, in editor
code, then loaddata in new db
https://docs.djangoproject.com/en/2.1/ref/django-admin/#dumpdata

Cheers

On Thu, Oct 11, 2018 at 10:41 AM Mohammad Aqib <mohd.a...@loansimple.in>
wrote:

> I know CLI commands to backup db and restore into another but in this case
> CLI would not work because previous db tables is different from new db
> tables.
>
> So, I have backup.sql file and need to read this file and dump the values
> into new db
>
> Or another option I know, is to connect server db and execute queries one
> by one. Which is very lengthy and horrible process.
>
> Is any other way to do this?
>
> On Thu, 11 Oct 2018, 10:03 pm Ryan Gedwill, <ryangedw...@gmail.com> wrote:
>
>> Depending on the SQL distribution you're using, there should be a couple
>> tools to do this without python using a CLI command or a basic SQL script.
>>
>> If you need to do it in python, use a basic python library (again,
>> depends on your sql distribution) to connect to your database and execute
>> the SQL command to execute the file.
>>
>> I only remember how to do this in postgres specifically, but you happen
>> to be using postgres as well, I can help further.
>>
>> On Thu, Oct 11, 2018 at 5:03 AM Mohammad Shareef M <shareef...@gmail.com>
>> wrote:
>>
>>> Create new database and Restore the backup file
>>>
>>> Thanks & Regards,
>>> Mahammad Shareef M
>>>  +919741482617
>>>  +971501340618
>>>  +971581756035
>>>
>>>
>>> On Thu, Oct 11, 2018 at 4:01 PM Mohammad Aqib <mohd.a...@loansimple.in>
>>> wrote:
>>>
>>>> Hi All,
>>>> I have a task to migrate all data into a new database using
>>>> "backup.sql" file.
>>>> How to write a Python script to do this task.
>>>>
>>>> Thanks
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/CAOh93ncV9awh9Y6GCC72FCY4XUO2eOSBWpB-TKH_RRmOk_4vZA%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAOh93ncV9awh9Y6GCC72FCY4XUO2eOSBWpB-TKH_RRmOk_4vZA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAPUAdBH1-wZeR3J%2BKFpFxnwQYWu3CsZxacoiPOOsv7VzqY3%2Brg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAPUAdBH1-wZeR3J%2BKFpFxnwQYWu3CsZxacoiPOOsv7VzqY3%2Brg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CALG8KeAXP%3DF4fzbV1PVMr0CyELHYr2pASRqZerDEt1%3DVbkX%2BSQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CALG8KeAXP%3DF4fzbV1PVMr0CyELHYr2pASRqZerDEt1%3DVbkX%2BSQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAOh93nedBas9h_s-5GdGpqV8EG0sNatAFkcz5NxeEsdVv%2BvczQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAOh93nedBas9h_s-5GdGpqV8EG0sNatAFkcz5NxeEsdVv%2BvczQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
att.
Carlos Rocha

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAM-7rO1BvgacnMhZQ_%2B%2BX4CtQEOxBB85JDrvKwQu6gGaDjJT0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to