code: def database_exists(name, **kwargs):
      
      with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
          res = query("SHOW DATABASES LIKE '%(name)s';" % {
              'name': name
          }, **kwargs)
  
      return res.succeeded and (res == name)
docs: Check if a MySQL database exists.