Wednesday, August 22, 2018

how to import serveral csv into database by using migrations.RunPython

Hello,

The class below didn't work if you use  migrations.RunPython several times.
Have you got an idea to manage double csv file importation into database ?

Thanks

Emmanuel

class Migration(migrations.Migration):

    dependencies = [
        ("contact", "0001_initial"),
    ]

    operations = [
         migrations.RunPython(
               lambda apps, schema_editor: import_countries(
               str(BASE_DIR / "contact" / "migrations" / "departement.csv")
             )
         ),
         migrations.RunPython(
             lambda apps, schema_editor: import_zipcode(
                 str(BASE_DIR / "contact" / "migrations" / "codepostal.csv")
             )
         ),
    ]

--
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+unsubscribe@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/a0c3fd68-9db2-462d-b122-9ea439e61ce4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment