Created
November 8, 2018 11:48
-
-
Save osoda/690462e801493d5e73b60c1e813e5d4d to your computer and use it in GitHub Desktop.
Import multiples dbs mysql that are listed in a file and this have in a dir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# If you have a dir whithout list, just whit all sql dump, you can use next script, | |
# that list all the files in a dir, into a file or multiples files: | |
# https://gist.github.com/osoda/69f21664352a55540ec18781c0ab7119 | |
import re | |
from subprocess import call | |
mysql="/usr/bin/mysql" | |
archivo = raw_input('Escriba el nombre del archivo que tiene las db: ') | |
with open('outputs/%s' %archivo, 'r') as f: | |
for line in f: | |
line = line.strip() | |
db = re.sub('\.sql$','',line) | |
cmdline = "mysql -uroot "+str(db) | |
rc = call(cmdline, stdin=open("manual/%s" %line), cwd=mysql) | |
print(str(line)+" (UP)") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment