Forums

Please help me on this i want to migrate my db from sqllite to mysql in django

Please help me on this i want to migrate my db from sqllite to mysql in django

everything seems to be fine untill time to loaddata to mysql db back am facing this error

python manage.py loaddata datadump.json Traceback (most recent call last): File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 71, in execute return self.cursor.execute(query, args) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/MySQLdb/cursors.py", line 209, in execute res = self._query(query) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/MySQLdb/cursors.py", line 315, in _query db.query(q) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/MySQLdb/connections.py", line 231, in query _mysql.connection.query(self, query) MySQLdb._exceptions.OperationalError: (1054, "Unknown column 'convertion_parcentage' in 'field list'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/core/management/init.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv self.execute(*args, cmd_options) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/core/management/base.py", line 353, in execute output = self.handle(*args, options) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 72, in handle self.loaddata(fixture_labels) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 113, in loaddata self.load_label(fixture_label) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 177, in load_label obj.save(using=self.using) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/core/serializers/base.py", line 219, in save models.Model.save_base(self.object, using=using, raw=True, kwargs) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/models/base.py", line 748, in save_base output = self.handle(*args, options) updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/models/base.py", line 812, in _save_table forced_update) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/models/base.py", line 861, in _do_update return filtered._update(values) > 0 File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/models/query.py", line 712, in _update return query.get_compiler(self.db).execute_sql(CURSOR) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1383, in execute_sql cursor = super().execute_sql(result_type) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1065, in execute_sql cursor.execute(sql, params) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/backends/utils.py", line 68, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappe rs return executor(sql, params, many, context) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/utils.py", line 89, in exit raise dj_exc_value.with_traceback(traceback) from exc_value File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 71, in execute return self.cursor.execute(query, args) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/MySQLdb/cursors.py", line 209, in execute res = self._query(query) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/MySQLdb/cursors.py", line 315, in _query db.query(q) File "/home/fastconnect/.virtualenvs/musa/lib/python3.7/site-packages/MySQLdb/connections.py", line 231, in query _mysql.connection.query(self, query) django.db.utils.OperationalError: Problem installing fixture '/home/fastconnect/simpledata/web/datadump.json': Could not load app.Netw ork(pk=1): (1054, "Unknown column 'convertion_parcentage' in 'field list'")

this is the json data i want to load i didnt copy all because of some sensitive information

[ { "model": "sites.site", "pk": 1, "fields": { "domain": "www.simpledata.com.ng", "name": "Simpledata" } }, { "model": "app.network", "pk": 1, "fields": { "name": "MTN", "status": "", "convertion_parcentage": null } }, { "model": "app.network", "pk": 2, "fields": { "name": "GLO", "status": "", "convertion_parcentage": null } }, { "model": "app.network", "pk": 3, "fields": { "name": "9MOBILE", "status": "", "convertion_parcentage": null } }, { "model": "app.network", "pk": 4, "fields": { "name": "AIRTEL", "status": "", "convertion_parcentage": null } }, { "model": "app.refund", "pk": 9, "fields": { "user_id": 13, "amount": 850 } }, { "model": "app.refund", "pk": 10, "fields": { "user_id": 161, "amount": 440 } }, { "model": "app.refund", "pk": 11, "fields": { "user_id": 92, "amount": 5000 } }, { "model": "app.refund", "pk": 12, "fields": { "user_id": 236, "amount": 2150 } }, { "model": "app.refund", "pk": 13, "fields": { "user_id": 873, "amount": 8000 } }, { "model": "app.refund", "pk": 14, "fields": { "user_id": 211, "amount": 3000 } }, { "model": "app.refund", "pk": 15, "fields": { "user_id": 911, "amount": 430 } }, { "model": "app.refund", "pk": 16, "fields": { "user_id": 904, "amount": 430 } }, { "model": "app.plan", "pk": 1, "fields": { "network": 1, "plan_size": 1.0, "plan_Volume": "GB", "plan_amount": 430, "plan_type": "", "month_validate": "3" } }, { "model": "app.plan", "pk": 3, "fields": { "network": 4, "plan_size": 1.5, "plan_Volume": "GB", "plan_amount": 940, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 4, "fields": { "network": 3, "plan_size": 1.0, "plan_Volume": "GB", "plan_amount": 600, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 6, "fields": { "network": 1, "plan_size": 2.0, "plan_Volume": "GB", "plan_amount": 860, "plan_type": "", "month_validate": "1 month" } }, { "model": "app.plan", "pk": 7, "fields": { "network": 2, "plan_size": 920.0, "plan_Volume": "MB", "plan_amount": 400, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 8, "fields": { "network": 1, "plan_size": 5.0, "plan_Volume": "GB", "plan_amount": 2150, "plan_type": "", "month_validate": "1 month" } }, { "model": "app.plan", "pk": 9, "fields": { "network": 2, "plan_size": 1.84, "plan_Volume": "GB", "plan_amount": 800, "plan_type": "", "month_validate": "1 month" } }, { "model": "app.plan", "pk": 10, "fields": { "network": 2, "plan_size": 4.5, "plan_Volume": "GB", "plan_amount": 1600, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 11, "fields": { "network": 2, "plan_size": 7.2, "plan_Volume": "GB", "plan_amount": 1900, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 12, "fields": { "network": 2, "plan_size": 8.75, "plan_Volume": "GB", "plan_amount": 2300, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 13, "fields": { "network": 2, "plan_size": 12.5, "plan_Volume": "GB", "plan_amount": 3200, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 14, "fields": { "network": 2, "plan_size": 15.6, "plan_Volume": "GB", "plan_amount": 4200, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 15, "fields": { "network": 2, "plan_size": 25.0, "plan_Volume": "GB", "plan_amount": 6500, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 16, "fields": { "network": 3, "plan_size": 2.0, "plan_Volume": "GB", "plan_amount": 1200, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 17, "fields": { "network": 3, "plan_size": 3.0, "plan_Volume": "GB", "plan_amount": 1800, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 18, "fields": { "network": 3, "plan_size": 4.0, "plan_Volume": "GB", "plan_amount": 2400, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 19, "fields": { "network": 3, "plan_size": 5.0, "plan_Volume": "GB", "plan_amount": 3000, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 20, "fields": { "network": 4, "plan_size": 4.5, "plan_Volume": "GB", "plan_amount": 1880, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 21, "fields": { "network": 1, "plan_size": 500.0, "plan_Volume": "MB", "plan_amount": 250, "plan_type": "", "month_validate": "1 month" } }, { "model": "app.plan", "pk": 22, "fields": { "network": 4, "plan_size": 6.0, "plan_Volume": "GB", "plan_amount": 2350, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 23, "fields": { "network": 1, "plan_size": 250.0, "plan_Volume": "MB", "plan_amount": 150, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 24, "fields": { "network": 4, "plan_size": 750.0, "plan_Volume": "MB", "plan_amount": 480, "plan_type": "", "month_validate": "2 weeks" } }, { "model": "app.plan", "pk": 25, "fields": { "network": 4, "plan_size": 11.0, "plan_Volume": "GB", "plan_amount": 3800, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 26, "fields": { "network": 1, "plan_size": 11.0, "plan_Volume": "GB", "plan_amount": 4500, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 27, "fields": { "network": 1, "plan_size": 25.0, "plan_Volume": "GB", "plan_amount": 9000, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 28, "fields": { "network": 1, "plan_size": 40.0, "plan_Volume": "GB", "plan_amount": 13000, "plan_type": "", "month_validate": "1" } }, { "model": "app.plan", "pk": 29, "fields": { "network": 1, "plan_size": 60.0, "plan_Volume": "GB", "plan_amount": 18000, "plan_type": "", "month_validate": "2 months" } }, { "model": "app.plan", "pk": 30, "fields": { "network": 1, "plan_size": 100.0, "plan_Volume": "GB", "plan_amount": 28000, "plan_type": "", "month_validate": "3 months" } }, { "model": "app.percentage", "pk": 1, "fields": { "network": 1, "percent": 80 } }, { "model": "app.percentage", "pk": 2, "fields": { "network": 2, "percent": 60 } }, { "model": "app.percentage", "pk": 3, "fields": { "network": 3, "percent": 67 } }, { "model": "app.percentage", "pk": 4, "fields": { "network": 4, "percent": 70 } }, { "model": "app.topuppercentage", "pk": 1, "fields": { "network": 1, "percent": 97 } }, { "model": "app.topuppercentage", "pk": 2, "fields": { "network": 2, "percent": 95 } }, { "model": "app.topuppercentage", "pk": 3, "fields": { "network": 3, "percent": 98 } }, { "model": "app.topuppercentage", "pk": 4, "fields": { "network": 4, "percent": 98 } }, { "model": "app.admin_number", "pk": 1, "fields": { "network": "MTN", "phone_number": "08168891448" } }, { "model": "app.admin_number", "pk": 2, "fields": { "network": "GLO", "phone_number": "08153152044" } }, { "model": "app.admin_number", "pk": 3, "fields": { "network": "AIRTEL", "phone_number": "08089621703" } }, { "model": "app.admin_number", "pk": 4, "fields": { "network": "9MOBILE", "phone_number": "08067y6tr6" } }, { "model": "app.couponcode", "pk": 103, "fields": { "Coupon_Code": "Fjdakaaj", "amount": "2000", "create_date": "2019-10-19T06:31:17Z", "ident": "36471b", "Used": true } }, { "model": "app.couponcode", "pk": 104, "fields": { "Coupon_Code": "Jlsajaks", "amount": "1000", "create_date": "2019-10-19T06:31:45Z", "ident": "75d1b8", "Used": true } }, { "model": "app.couponcode", "pk": 105, "fields": { "Coupon_Code": "Jdkdshjg", "amount": "2000", "create_date": "2019-10-19T07:56:10Z", "ident": "580456", "Used": true } }, { "model": "app.couponcode", "pk": 106, "fields": { "Coupon_Code": "Gksakdah", "amount": "5000", "create_date": "2019-10-22T20:56:03Z", "ident": "65e599", "Used": true } }, { "model": "app.couponcode", "pk": 107, "fields": { "Coupon_Code": "Jkdaksk", "amount": "100000", "create_date": "2019-10-24T07:23:53Z", "ident": "740cd6", "Used": true } }, { "model": "app.couponcode", "pk": 108, "fields": { "Coupon_Code": "GdjsksNaj", "amount": "2000", "create_date": "2019-10-26T09:16:49Z", "ident": "95d4b5", "Used": true } }, { "model": "app.couponcode", "pk": 109, "fields": { "Coupon_Code": "Yjdhsjdky", "amount": "2000", "create_date": "2019-10-26T20:06:54Z", "ident": "148f1c", "Used": true } }, { "model": "app.couponcode", "pk": 110, "fields": { "Coupon_Code": "Kogsklsf", "amount": "100000", "create_date": "2019-10-28T20:40:09Z", "ident": "53dba0", "Used": true } }, { "model": "app.couponcode", "pk": 111, "fields": { "Coupon_Code": "Jfkaksldk", "amount": "2000", "create_date": "2019-10-30T12:18:50Z", "ident": "563c27", "Used": true } }, { "model": "app.couponcode", "pk": 112, "fields": { "Coupon_Code": "Ikczkzjzk", "amount": "10000", "create_date": "2019-10-31T19:38:32Z", "ident": "235a54", "Used": true } }, { "model": "app.couponcode", "pk": 113, "fields": { "Coupon_Code": "Nkdksksf", "amount": "100000", "create_date": "2019-11-01T19:58:14Z", "ident": "25de6e", "Used": true } }, { "model": "app.couponcode", "pk": 114, "fields": { "Coupon_Code": "Jgkxksldzk", "amount": "5000", "create_date": "2019-11-02T21:54:47Z", "ident": "45c6a4", "Used": true } }, { "model": "app.couponcode", "pk": 115, "fields": { "Coupon_Code": "Ijfjzldlsyg", "amount": "2000", "create_date": "2019-11-03T10:07:09Z", "ident": "539bc0", "Used": true } }, { "model": "app.couponcode", "pk": 116, "fields": { "Coupon_Code": "Jfkskdkdm", "amount": "5000", "create_date": "2019-11-03T21:30:51Z", "ident": "335a56", "Used": true } }, { "model": "app.couponcode", "pk": 117, "fields": { "Coupon_Code": "Kdksksah", "amount": "2000", "create_date": "2019-11-04T14:48:14Z", "ident": "6362bc", "Used": true } }, { "model": "app.couponcode", "pk": 118, "fields": { "Coupon_Code": "JdkKsafja", "amount": "5000", "create_date": "2019-11-04T20:19:01Z", "ident": "12e6de", "Used": true } }, { "model": "app.couponcode", "pk": 119, "fields": { "Coupon_Code": "Kdjsjklsdt", "amount": "100000", "create_date": "2019-11-05T05:38:14Z", "ident": "822cd8", "Used": true } }, { "model": "app.automation_control", "pk": 3, "fields": { "Network_good": true, "network_name": 1 } }, { "model": "app.automation_control", "pk": 4, "fields": { "Network_good": true, "network_name": 2 } }, { "model": "app.automation_control_cable", "pk": 1, "fields": { "name": "cablesub", "automation_on": true } }, { "model": "app.automation_control_topup", "pk": 1, "fields": { "automation_on": false, "network_name": 1 } }, { "model": "app.automation_control_topup", "pk": 2, "fields": { "automation_on": true, "network_name": 2 } }, { "model": "app.cable", "pk": 1, "fields": { "name": "GOTV", "status": "Strong" } }, { "model": "app.cable", "pk": 2, "fields": { "name": "DSTV", "status": "Strong" } }, { "model": "app.cable", "pk": 3, "fields": { "name": "STARTIME", "status": "Strong" } }, { "model": "app.cableplan", "pk": 1, "fields": { "cablename": 1, "plan_amount": 400, "package": "GOtv Lite" } }, { "model": "app.cableplan", "pk": 2, "fields": { "cablename": 1, "plan_amount": 1250, "package": "GOtv Value" } }, { "model": "app.cableplan", "pk": 3, "fields": { "cablename": 1, "plan_amount": 1900, "package": "GOtv Plus" } }, { "model": "app.cableplan", "pk": 4, "fields": { "cablename": 1, "plan_amount": 3200, "package": "GOtv Max" } }, { "model": "app.cableplan", "pk": 5, "fields": { "cablename": 2, "plan_amount": 2000, "package": "DStv Access" }....more

and my migrations table

migrations.CreateModel( name='Network', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(choices=[('MTN', 'MTN'), ('GLO', 'GLO'), ('AIRTEL', 'AIRTEL'), ('9MOBILE', '9MOBILE'), ('SMILE', 'SMILE'), ('SPECTRANET', 'SPECTRANET'), ('SWIFT', 'SWIFT')], max_length=30, unique=True)), ('status', models.CharField(choices=[('Fair', 'Fair'), ('Bad', 'Bad'), ('Strong', 'Strong')], max_length=30)), ('convertion_parcentage', models.IntegerField(blank=True, null=True)), ], ),

Does your table in question actually have a column called convertion_parcentage?

Yes

Have you run ./manage.py migrate before ./manage.py loaddata?