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.
Welcome to civicrm stackexchange.
Couple of options here.
- One option is to split your file into smaller chunks.
- 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.
- 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.
- 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.