from pathlib import Path


def gen_geojson(conn, model_num):
    """ Queries postgres and returns a geoJSON file with boundary data
    and properties that give us demographics and transit access data.
    
     Parameters
     ----------
     model_num: int
         The number of the model in question

     Returns
     -------
     geoJSON: geoJSON file
         A file where the rows are OAs (the exact number will depend on 
         the query) and the columns are geometry, demographics, and a 
         metric value. 
    
    """
    # path to sql file (model number is currently hardcoded!)
    sql_filename = "/Users/james/Documents/DSSG/DSSG19-WMCA/sql/fetch_geoJSON.sql"    
    # read sql
    query = Path(sql_filename).read_text()
    # query postgres
    geoJSON = conn.execute(query).fetchall()
    return(geoJSON)