python fabric mysql privileges

杀马特。学长 韩版系。学妹 提交于 2019-12-02 02:54:00

问题


Trying to set mysql user privileges with fabric.

run("mysql -u %s -p%s -e 'grant all on %s.* to '%s'@'localhost' identified by 'PASSWORD'" % (user, dbpasswd, account))

Error

TypeError: not enough arguments for format string

Any idea ? Thanks a lot !

run('mysql -u %s -p%s -e "grant all on %s.* to '%s\'@\'localhost' identified by 'PASSWORD'"' % (user, dbpasswd, account, account))

SyntaxError: unexpected character after line continuation character

回答1:


Change your tuple to (user, dbpasswd, account, user) and you should be good. This error happens because you have 4 replacements tokens (%s) but only have 3 items in your tuple.



来源:https://stackoverflow.com/questions/11392721/python-fabric-mysql-privileges

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!