There are more than such records in the database. each record contains the Chinese name of the region and the English name of the region (for example,). I want to use the redis queue lpush and rpop for batch update, I have already written the SQL statement (for example, I wrote the code in this way (for example). I wrote more than 3 thousand SQL statements...
There are more than such records in the database. each record contains the Chinese name of the region and the English name of the region (for example)
Now I want to use the redis queue lpush and rpop for batch update. I have written the SQL statement (for example)
I wrote the code like this (for example). I saved more than SQL statements into the list (lpush), and prepared to execute each time (rpop) one by one, I don't know how to write it next. I want to ask you how to write it next. now I have put the SQL statement into the list; and I want to view the list value under cli. Chinese characters seem to contain garbled characters (such ), I added -- raw when I started the cli. please answer it.
Thank you ~
Reply content:
There are more than such records in the database. each record contains the Chinese name of the region and the English name of the region (for example)
Now I want to use the redis queue lpush and rpop for batch update. I have written the SQL statement (for example)
I wrote the code like this (for example). I saved more than SQL statements into the list (lpush), and prepared to execute each time (rpop) one by one, I don't know how to write it next. I want to ask you how to write it next. now I have put the SQL statement into the list; and I want to view the list value under cli. Chinese characters seem to contain garbled characters (such ), I added -- raw when I started the cli. please answer it.
Thank you ~
Thank you!
In fact, you don't need redis. you can put all the SQL statements in one file and read and execute one SQL statement?
Function getSql () {$ fp = fopen(' SQL .txt ', 'r'); while (! Feof ($ fp) {yield fgets ($ fp) ;}} foreach (getSql () as $ SQL) {executeSql ($ SQL);} function executeSql () {// execution Statement}
Insert into base_region (region_name, en_name) values ('China', 'Zhongguo'), ('Beijing', 'Beijing '),..., ('Shanghai', 'Shanghai') on duplicate key update en_name = values (en_name );
A SQL statement with a very low overhead can be done (the performance of a database connection is similar to that of batch insert into data ).
Pay attention to the following two points:
You need to splice the values of () in values (), (), and () using a for loop.
Region_name must be a unique index. you can add a unique index to this field temporarily. after the SQL statement is executed, drop it.