Import sql data from a large file when installing plugin

I’m making my first plugin and I need to import about 31,000 records from a sql file into the wpdb when the plugin first gets installed by the user, but it is only importing about half of them only, around 18,000 records.

In the install function I have these lines to INSERT the data:

Read More
$sql = file_get_contents(ABSPATH . 'wp-content/plugins/plugin-name/sql.sql');
dbDelta($sql);

Within the sql file I have this:

<? $sql = "CREATE TABLE IF NOT EXISTS $table_name (
`book` int(11) default NULL, 
`chapter` int(11) default NULL,
`verse` int(11) default NULL, 
`text` text
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO $table_name VALUES 
(4, 6, 27, 'text string here'),
(4, 6, 28, 'text string here'),
(4, 6, 29, 'text string here'),
(4, 6, 30, 'text string here');
"; ?>

I have tried using wpdb->query and wpdb->prepare but it is still not working. I have tried so many different ways and spent lots of hours trying to figure it out but it doesn’t work.

What can I do so that I can import 100% of the records when the plugin gets installed?

Thank you in advance.

Related posts