code: def user_exists(name, host='localhost', **kwargs):
      
      with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
          res = query("""
              use mysql;
              SELECT COUNT(*) FROM user
                  WHERE User = '%(name)s' AND Host = '%(host)s';
              """ % {
                  'name': name,
                  'host': host,
              }, **kwargs)
      return res.succeeded and (int(res) == 1)
docs: Check if a MySQL user exists.