2

Can some one give a code to how to import contacts in civicrm by using script line command. I a have a 45000 contacts and importing from civicrm interface i am getting gateway timeout error. I need help in importing contacts from CLI.

2

Welcome to civicrm stackexchange.

Couple of options here.

  1. One option is to split your file into smaller chunks.
  2. If you have the ability to alter the php settings on the server you can change these to increase the time over which the import can run the option you probably want to look at is max_execution_time - in your php ini file. Depending on your hosting this will be in different places.
  3. Depending on whether your site is live or not - if you are in the set up stage you could always look at exporting your site to a local machine which you can edit the php ini on. then copy the database back - however if you don't have a local dev environment set up this might require a lot of set up.
  4. If you want to dive into the code - then you'll need to write some custom code to do this. You are probably best to import via the api - that way you can let civicrm take care of making sure everything in the database matches up correctly. As a first step I'd checkout the api explorer under Support -> Developer Api Explorer v3. You might want to check https://github.com/eileenmcnaughton/nz.co.fuzion.csvimport for inspiration -> and don't forget you'll need to call civicrm_initialize() prior to making an api call. You can use drush,wp or cv to evaluate a file against the site.

If you really wanted to court disaster you could try importing contacts directly into the sql tables - but I wouldn't recommend this as a first step.

  • 1
    I strongly recommend not importing with SQL. This bypasses a great deal of validation, greeting/display name processing, geocoding, and more. – Jon G - Megaphone Tech Nov 30 at 20:27
  • Totally agree have edited to remove some of the details. – Luke Stewart Dec 1 at 21:00

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.