0

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.