def get_flowpath(cursor, scenario, huc12, fpath):
    """Get or create a database flowpath identifier

    Args:
      cursor (psycopg2.cursor): database cursor
      huc12 (str): HUC12 identifier
      fpath (int): the flowpath id value for this HUC12

    Returns:
      int the value of this huc12 flowpath
    """
    cursor.execute(
        "SELECT fid from flowpaths where huc_12 = %s and fpath = %s "
        "and scenario = %s",
        (huc12, fpath, scenario),
    )
    if cursor.rowcount == 0:
        cursor.execute(
            "INSERT into flowpaths(huc_12, fpath, scenario) "
            "values (%s, %s, %s) RETURNING fid",
            (huc12, fpath, scenario),
        )
    return cursor.fetchone()[0]