The database [mysql] is spinning on the server - new files with migrations have appeared, about a few dozen. Question: Is it possible to roll all these migrations to the base with the help of some script for mysql or mysqldump (perhaps somehow with the help of a workbench) in order not to perform them one by one?)

  • What are “migration files”, what is in them? If sql - then feed it just to the mysql command. And if not sql - the means by which you prepared them - Mike
  • mysql - scripts with content like create table N, add field in table M, etc. - oleg.vorobiov
  • one
    If under unix, then the simplest script like cat *.sql | mysql -u пользователь -pпароль имя-базы cat *.sql | mysql -u пользователь -pпароль имя-базы mask *.sql only to make it so that it captures all the necessary files - Mike
  • unfortunately, 'windows') but thought understood, thank you) and as for the workbench - if he can do such things, do not tell me? - oleg.vorobiov
  • I don’t know about it, it’s just a graphic environment. why should he? On the other hand, he has mysql.exe in his directory, something tells me that he can do everything on the command line, which means you can do some .bat - Mike

1 answer 1

If someone comes in handy. Python script:

 import os current_directory = "ваш_путь_к_файлам" # чтобы mysql работала с консоли, добавьте # путь к mysql_folder в path for filename in os.listdir(current_directory): full_path = current_directory + filename query = "mysql -u username -puserpass dbname < " + full_path os.system(query);