Bulk import from another database to a Django powered one

I have created the models for a new Django app which Im re-writing from a app written in CodeIgniter 3.

Let’s say I wanted to migrate the customers table from CI to Django - is it safe to write a separate script to query the CI database and output raw SQL insert statements which I’ll run on the new database ?

Is it safe ? Or do I have to output something like to execute in shell ?

Customer.objects.bulk_create([
...     Customer(name='John'),
...     Customer(name='Mary'),
])

What makes you think that it might not be safe? (What are you concerned about?)

I meant, if running raw SQL statements safe ? Or is running bulk_create safer ?

Unfortunately, “safe” is a vague term and is not an absolute quantity.

To try and rephrase, what is the root issue or concern behind this question? What do you mean by “safe” in this context? (What are you thinking might happen?)

I thought if data is entered via ORM via shell or otherwise the data would be inserted post validation. On the other hand, via raw SQL, its just a dump of rows.

That is not an accurate assumption. The bulk_ operations bypass the model methods and operate directly by executing SQL. (See QuerySet API reference | Django documentation | Django) If you want the data validated before insertion, you’ll need to ensure it happens either way.