<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_db(with_postgis=False):
 """ Creates the local database. :param with_postgis: If ``True``, the postgis extension will be installed. """

    local_machine()
    local('psql {0} -c "CREATE USER {1} WITH PASSWORD \'{2}\'"'.format(
        USER_AND_HOST, env.db_role, DB_PASSWORD))
    local('psql {0} -c "CREATE DATABASE {1} ENCODING \'UTF8\'"'.format(
        USER_AND_HOST, env.db_name))
    if with_postgis:
        local('psql {0} {1} -c "CREATE EXTENSION postgis"'.format(
            USER_AND_HOST, env.db_name))
    local('psql {0} -c "GRANT ALL PRIVILEGES ON DATABASE {1}'
          ' to {2}"'.format(USER_AND_HOST, env.db_name, env.db_role))
    local('psql {0} -c "GRANT ALL PRIVILEGES ON ALL TABLES'
          ' IN SCHEMA public TO {1}"'.format(
              USER_AND_HOST, env.db_role))