Reputation: 155
I have a substantial amount of data in XML files that needs to be loaded into MySQL database.
i.e. in year 2012 folder, i have about 52 xml files, and one loadStatements.sql query file for all XML. The loadStatements.sql has the following lines...just a few here.
use uspto2012;
LOAD XML LOCAL INFILE 'H:/uspto_db/mysql/2012/ipa120126/ipa120126-01_sql.xml' INTO TABLE assignee ROWS IDENTIFIED BY '<assignee>';
LOAD XML LOCAL INFILE 'H:/uspto_db/mysql/2012/ipa120126/ipa120126-01_sql.xml' INTO TABLE claims ROWS IDENTIFIED BY '<claims>';
LOAD XML LOCAL INFILE 'H:/uspto_db/mysql/2012/ipa120126/ipa120126-01_sql.xml' INTO TABLE description ROWS IDENTIFIED BY '<description>';
LOAD XML LOCAL INFILE 'H:/uspto_db/mysql/2012/ipa120126/ipa120126-01_sql.xml' INTO TABLE info ROWS IDENTIFIED BY '<info>';
Now if I call this file from MySQL workbench or shell, it runs ok. Now I have hundreds of these files and It is tidious to load each file manually.
I need one master file that can call these load files. i.e
use uspto2012;
SOURCE H:/uspto_db/mysql/2012/ipa120126/loadStatements.sql;
SOURCE H:/uspto_db/mysql/2012/ipa120202/loadStatements.sql;
SOURCE H:/uspto_db/mysql/2012/ipa120209/loadStatements.sql;
SOURCE H:/uspto_db/mysql/2012/ipa120216/loadStatements.sql;
But when I try to run this file, I get error, from mwb. "Source is not recognized as MySQL command"
I kindly need help on a better way to achieve this.
Upvotes: 1
Views: 1248
Reputation: 92805
SOURCE
is mysql CLI command.
If you already created your master file you can do this though
C:\> mysql -uuser -p < H:/path/to/your/matser_file.sql
or
C:\> mysql -uuser -p -e "source H:/path/to/your/matser_file.sql"
Upvotes: 1