dumpdata

Django dumpdata output is empty

谁说我不能喝 提交于 2020-01-16 18:39:08
问题 we have a Django 1.4.5 project with a PostgreSQL 9.3 backend. Unfortunately we are facing the problems when attempting to create fixtures for one of the apps (which is called sddb ). The database is full of objects that belong to sddb app: (venv)[root@dl380p1 team112]# ./manage.py shell >>> from sddb.models.media import Metadata >>> len(Metadata.objects.all()) 22916 However the dumpdata output is empty: (venv)[root@dl380p1 team112]# ./manage.py dumpdata sddb [] Explicit pointing of database

Django dumpdata output is empty

↘锁芯ラ 提交于 2020-01-16 18:39:06
问题 we have a Django 1.4.5 project with a PostgreSQL 9.3 backend. Unfortunately we are facing the problems when attempting to create fixtures for one of the apps (which is called sddb ). The database is full of objects that belong to sddb app: (venv)[root@dl380p1 team112]# ./manage.py shell >>> from sddb.models.media import Metadata >>> len(Metadata.objects.all()) 22916 However the dumpdata output is empty: (venv)[root@dl380p1 team112]# ./manage.py dumpdata sddb [] Explicit pointing of database

Django dump data for a single model?

ε祈祈猫儿з 提交于 2019-12-17 15:05:39
问题 Can I perform a dumpdata in Django on just a single model, rather than the whole app, and if so, how? For an app it would be: python manage.py dumpdata myapp However, I want some specific model, such as "myapp.mymodel" to be dumped. The reason being, I have some huge, 3 million records plus, datasets in the same app that I would not like dumped. 回答1: As of version 1.1 and greater, the Django dumpdata management command allows you to dump data from individual tables: ./manage.py dumpdata

django-admin.py dumpdata to SQL statements

拈花ヽ惹草 提交于 2019-12-12 09:48:24
问题 I'm trying to dump my data to SQL statements. the django-admin.py dumpdata provides only json,xml,yaml. so: does someone know a good way to do it?! I tried that: def sqldumper(model): result = "" units = model.objects.all().values() for unit in units: statement = "INSERT INTO myapp.model "+str(tuple(unit.keys())).replace("'", "")+" VALUES " + str(tuple(unit.values()))+"\r\n" result+=statement return result so I'm going over the model values myself, and make the INSERT statement myself. then I

django-admin.py dumpdata to SQL statements

元气小坏坏 提交于 2019-12-05 18:41:13
I'm trying to dump my data to SQL statements. the django-admin.py dumpdata provides only json,xml,yaml. so: does someone know a good way to do it?! I tried that: def sqldumper(model): result = "" units = model.objects.all().values() for unit in units: statement = "INSERT INTO myapp.model "+str(tuple(unit.keys())).replace("'", "")+" VALUES " + str(tuple(unit.values()))+"\r\n" result+=statement return result so I'm going over the model values myself, and make the INSERT statement myself. then I thought of using "django-admin.py sql" to get the "CREATE" statement.. but then I don't know how to

Use Django dumpdata to dump a subset of overall data?

有些话、适合烂在心里 提交于 2019-12-03 15:31:32
问题 I'm trying to use dumpdata to generate JSON for a database that is sufficiently large for django to take a long, long time to output. Is there any way to dump only a subset of the fields; say, 100, for testing? I'm using MySQL and Django 1.0. 回答1: A 3rd party django app, django-test-utils contains a makefixture command implementation which is basically a smarter dumpdata. You can specify exact model names with ID ranges to export (and it will follow related objects) Example: manage.py

Django dumpdata UTF-8 (Unicode)

随声附和 提交于 2019-12-03 11:31:37
问题 Is there a easy way to dump UTF-8 data from a database? I know this command: manage.py dumpdata > mydata.json But the data I got in the file mydata.json, Unicode data looks like: "name": "\u4e1c\u6cf0\u9999\u6e2f\u4e94\u91d1\u6709\u9650\u516c\u53f8" I would like to see a real Unicode string like 全球卫星定位系统 (Chinese). 回答1: django-admin.py dumpdata yourapp could dump for that purpose. Or if you use MySQL, you could use the mysqldump command to dump the whole database. And this thread has many

Use Django dumpdata to dump a subset of overall data?

丶灬走出姿态 提交于 2019-12-03 05:14:13
I'm trying to use dumpdata to generate JSON for a database that is sufficiently large for django to take a long, long time to output. Is there any way to dump only a subset of the fields; say, 100, for testing? I'm using MySQL and Django 1.0. A 3rd party django app, django-test-utils contains a makefixture command implementation which is basically a smarter dumpdata. You can specify exact model names with ID ranges to export (and it will follow related objects) Example: manage.py makefixture --format=xml --indent=4 proj.appname.modelname[1:101] > test.xml rrauenza See also Django Selective

Django dumpdata UTF-8 (Unicode)

半世苍凉 提交于 2019-12-03 02:57:33
Is there a easy way to dump UTF-8 data from a database? I know this command: manage.py dumpdata > mydata.json But the data I got in the file mydata.json, Unicode data looks like: "name": "\u4e1c\u6cf0\u9999\u6e2f\u4e94\u91d1\u6709\u9650\u516c\u53f8" I would like to see a real Unicode string like 全球卫星定位系统 (Chinese). YOU django-admin.py dumpdata yourapp could dump for that purpose. Or if you use MySQL, you could use the mysqldump command to dump the whole database. And this thread has many ways to dump data, including manual methods. UPDATE : because OP edited the question. To convert from JSON

Django backup strategy with dumpdata and migrations

烂漫一生 提交于 2019-11-30 21:25:29
As in this question , I set up a dumpdata -based backup system for my database. The setup is akin to running a cron script that calls dumpdata and moves the backup to a remote server, with the aim of simply using loaddata to recover the database. However, I'm not sure this plays well with migrations . loaddata now has an ignorenonexistent switch to deal with deleted models/fields, but it is not able to resolve cases where columns were added with one-off defaults or apply RunPython code. The way I see it, there are two sub-problems to address: Tag each dumpdata output file with the current