mysql_db now supports import and dump of gzip and bzip2 compressed files
This commit is contained in:
parent
e1ff809d1a
commit
85ed9af959
1 changed files with 16 additions and 6 deletions
|
@ -117,15 +117,25 @@ def db_delete(cursor, db):
|
|||
return True
|
||||
|
||||
def db_dump(host, user, password, db_name, target):
|
||||
res = os.system("/usr/bin/mysqldump -q -h "+host+" -u "+user+ " --password="+password+" "
|
||||
+db_name+" > "
|
||||
+target)
|
||||
cmd = '/usr/bin/mysqldump -q -h ' + host + ' -u ' + user + ' --password=' + password + ' ' + db_name
|
||||
if os.path.splitext(target)[-1] == '.gz':
|
||||
cmd = cmd + ' | gzip > ' + target
|
||||
elif os.path.splitext(target)[-1] == '.bz2':
|
||||
cmd = cmd + ' | bzip2 > ' + target
|
||||
else:
|
||||
cmd = cmd + ' > ' + target
|
||||
res = os.system(cmd)
|
||||
return (res == 0)
|
||||
|
||||
def db_import(host, user, password, db_name, target):
|
||||
res = os.system("/usr/bin/mysql -h "+host+" -u "+user+" --password="+password+" "
|
||||
+db_name+" < "
|
||||
+target)
|
||||
cmd = '/usr/bin/mysql -h ' + host + ' -u ' + user + ' --password=' + password + ' ' + db_name
|
||||
if os.path.splitext(target)[-1] == '.gz':
|
||||
cmd = 'gunzip < ' + target + ' | ' + cmd
|
||||
elif os.path.splitext(target)[-1] == '.bz2':
|
||||
cmd = 'bunzip2 < ' + target + ' | ' + cmd
|
||||
else:
|
||||
cmd = cmd + ' < ' + target
|
||||
res = os.system(cmd)
|
||||
return (res == 0)
|
||||
|
||||
def db_create(cursor, db, encoding, collation):
|
||||
|
|
Loading…
Reference in a new issue