Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy all the data from main server database to the local sqlite database to use locally?

Tags:

python

django

Local database setting-

`DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
 }`

main database setting-

`DATABASES = {
    'default': {
        'ENGINE':'django.db.backends.mysql',
        'NAME': '******',
        'USER': '******',
        'PASSWORD': '********',
        'HOST': '******', 
       'PORT': '****',
    }
}`

I did it from the git project python manage.py dumpdata > all.json . But then I don't know what to do next like how to use this json file to update local database by which commands.

I am very beginner to this. kindly help me solve this problem.

like image 530
Bhirendra Kumar Sahu Avatar asked Jan 22 '26 05:01

Bhirendra Kumar Sahu


1 Answers

You should always use an RDBMS from the same vendor at both ends. And preferably the same version. Though ORMs such as Django's are supposed to be database agnostic, there are still many subtle differences between different vendor's products. Sqlite for example is the least feature complete of the popular open source databases. If you use sqlite in development, and postgresql in production, you are limiting yourself to the set of features that sqlite has. But postgresql has many more. Right end of sermon.

At the live server do

python manage.py dumpdata > data.json

Then copy the file over to the local machine and do:

python manage.py loaddata data.json
like image 167
e4c5 Avatar answered Jan 23 '26 20:01

e4c5



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!