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.
-
I don't understand why you tagged this as webform-civicrm– petednz - fuzion ♦Commented Nov 27, 2019 at 18:32
-
removed that tag– KarinG - Semper ITCommented Nov 28, 2019 at 1:12
-
2Possible duplicate of How do I import contacts through the command line?– Jon G - Megaphone TechCommented Nov 30, 2019 at 20:29
Add a comment
|
1 Answer
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.
-
1I strongly recommend not importing with SQL. This bypasses a great deal of validation, greeting/display name processing, geocoding, and more. Commented Nov 30, 2019 at 20:27
-
Totally agree have edited to remove some of the details. Commented Dec 1, 2019 at 21:00