pyexcel / pyexcel-io

One interface to read and write the data in various excel formats, import the data into and export the data from databases
http://io.pyexcel.org
Other
58 stars 20 forks source link

Expose control over Django bulk_save option #46

Closed ShaheedHaque closed 6 years ago

ShaheedHaque commented 6 years ago

I'm running into an issue with Django's QuerySet.bulk_create() on multi-table inheritance which might be addressed in some cases. The use of this feature is controlled using the bulk_save option on pyexcel_io.database.importers.django.DjangoModelWriter...however, this is not exposed by pyexcel_io.database.importers.django.DjangoBookWriter:

        sheet_writer = DjangoModelWriter(
           self.__importer, model,
           batch_size=self._keywords.get('batch_size', None))

A simple patch to address this would be to change that to:

        sheet_writer = DjangoModelWriter(
           self.__importer, model,
           batch_size=self._keywords.get('batch_size', None),
           bulk_save=self._keywords.get('bulk_save', None))

or (unless there is some reason to limit what is passed?) possibly even:

        sheet_writer = DjangoModelWriter(
           self.__importer, model, **self._keywords)

Higher up, the ability to specify bulk_save is present in pyexcel.internal.core.save_sheet and save_book but is not exposed by pyexcel.internal.meta.BookMeta.save_to_django_models. This would need to be trivially addressed too.

FWIW, I'm presently using pyexcel-io 0.5.4, but I see that master (as above) also currently has this issue.

chfw commented 6 years ago

I am sorry for the delay. Please try it. I have chosen the first suggestion. Will release it soon.

ShaheedHaque commented 6 years ago

Thanks. See my comment on the commit.

On 10 Jan 2018 17:07, "jaska" notifications@github.com wrote:

I am sorry for the delay. Please try it. I have chosen the first suggestion. Will release it soon.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pyexcel/pyexcel-io/issues/46#issuecomment-356668575, or mute the thread https://github.com/notifications/unsubscribe-auth/AEp7KeLqLohpxu1UUUkpm00BTgvBfjlCks5tJO4rgaJpZM4ROJs4 .

chfw commented 6 years ago

please take latest pyexcel, pyexcel-io and django-excel.

ShaheedHaque commented 6 years ago

I don't see a new package for django-excel? Pypi still seems to be on 0.0.9 which I believe predates the fix. (I do see pyexcel has been bumped to 0.5.7 and pyexcel-io to 0.5.6). Did the push of 0.0.10 to Pypi fail?

chfw commented 6 years ago

Hey, my apologies. I forgot to publish django-excel v0.0.10 to pypi last night. now it is there.

ShaheedHaque commented 6 years ago

Thanks, that seems to work nicely.