mysql.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:charm-percona-cluster 作者: openstack 项目源码 文件源码
def grant_exists(self, db_name, db_user, remote_ip):
        cursor = self.connection.cursor()
        priv_string = "GRANT ALL PRIVILEGES ON `{}`.* " \
                      "TO '{}'@'{}'".format(db_name, db_user, remote_ip)
        try:
            cursor.execute("SHOW GRANTS for '{}'@'{}'".format(db_user,
                                                              remote_ip))
            grants = [i[0] for i in cursor.fetchall()]
        except MySQLdb.OperationalError:
            return False
        finally:
            cursor.close()

        # TODO: review for different grants
        return priv_string in grants
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号