What would be 'the best' hook function to use in the custom module installation to import entity data? This is supposed to be a one-time activity during the module installation only, after entity schema is built in the database and entities are initialized (to be able to use Entity API in the data import).


For one time import of data, when installing a module, use hook_install. This can be used to populate the database just after tables are created, provided your module also implements hook_schema.

You do not want to use hook_enable. If you used this, the database would be re-populated every time the module was re-enabled after being temporary disabled.

| improve this answer | |
  • Thank you, hook_install definitely looks more proper, and it seems to run after custom modules are loaded as well, so can use definitions of custom entities with Entity API. – al_mc Oct 11 '13 at 13:10

... just found, could be hook_enable() if I'm not mistaken about its usage

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.