我想在python腳本中保存mysql數據庫轉儲。以下是我有:Mysqldump與python
filepath = os.path.join(BACKUPS_FOLDER, '%s.sql' % date)
print filepath # /Users/david/Desktop/updates/_backups/2013-04-07.sql
subprocess.call(shlex.split('mysqldump -u root updates > %s' % filepath))
我得到以下錯誤:
mysqldump: Couldn't find table: ">"
我在做什麼錯誤嗎?
什麼,當你用引號括起來%S會怎樣? ''%s'' – seanbreeden 2013-04-07 22:52:55
我想你在調用mysqldump時沒有shell,所以它會通過'>'作爲參數(在這種情況下作爲表名) – agim 2013-04-07 22:57:19