Skip to content

Instantly share code, notes, and snippets.

@osoda
Created November 8, 2018 11:48
Show Gist options
  • Save osoda/690462e801493d5e73b60c1e813e5d4d to your computer and use it in GitHub Desktop.
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
#!/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