Nicolas D
Nicolas D

Reputation: 1222

Magento include a .sql file in setup script

I am wondering if there is a way to define a .sql file as source in a setup script. I have a huge .sql file and I don't think it is pretty to paste it in my php as this.

my file is composed of 60k insert into lines.

Of course I know I can do a fopen on my .sql file, so I am not blocked but I was wondering if there is a native functionality that can do it.

Thanks

Upvotes: 0

Views: 494

Answers (1)

Mukesh
Mukesh

Reputation: 7778

If you are developing a custom module in Magento and you want to import some records in the Magento with your module.Then you can accomplish this using following approach.

Create a .sql file at the mentioned location in your module.

app/code/local/Namespace/Modulename/data/modulename_setup/data-install-1.0.sql

INSERT INTO sample_table (id, value) VALUES (1, 'one');
-----
-----

First try a test run on development environment with only few lines of sql query.(As you are having 60K lines in your file.)

I found this solution on blog by Ryan.

Please refer for more information Magento Installation Scripts

Upvotes: 1

Related Questions