def api(from_iata, to_iata, departure_date, return_date):
    """Takes the parameters and returns a price response from the cache"""
    with std_connection() as conn:

        SQL = FULLY_QUALIFIED_PRICE_QUERY

        filters = {
            "from_iata": from_iata,
            "to_iata": to_iata,
            "departure_date": departure_date,
            "return_date": return_date
            }

        rows = conn.execute(SQL, filters)
        res = json.dumps(rows.fetchall())

        return parcel_json_response(res)
Esempio n. 2
0
def api(from_iata, to_iata, departure_date, return_date):
    """Takes the parameters and returns a price response from the cache"""
    with std_connection() as conn:

        SQL = FULLY_QUALIFIED_PRICE_QUERY

        filters = {
            "from_iata": from_iata,
            "to_iata": to_iata,
            "departure_date": departure_date,
            "return_date": return_date
        }

        rows = conn.execute(SQL, filters)
        res = json.dumps(rows.fetchall())

        return parcel_json_response(res)
def db_init(data_file, debug=True):
    """wupes and initialises the database with the file specified"""

    # drop the database
    if os.path.isfile(DATABASE_NAME):
        os.remove(DATABASE_NAME)

    # Get a connection to the database (making a new one in the process)
    conn = std_connection()

    # Create the table
    create_prices_table(conn)

    # Load the table from the file.
    data = read_data_file(data_file)

    # Insert it
    insert_price_data(conn, data, debug)
def db_init(data_file, debug = True):
    """wupes and initialises the database with the file specified"""

    # drop the database
    if os.path.isfile(DATABASE_NAME):
        os.remove(DATABASE_NAME)

    # Get a connection to the database (making a new one in the process)
    conn = std_connection()

    # Create the table
    create_prices_table(conn)

    # Load the table from the file.
    data = read_data_file(data_file)

    # Insert it
    insert_price_data(conn, data, debug)
def all_routes():
    """returns all the routes we have!"""
    with std_connection() as conn:
        rows = conn.execute(ALL_PRICES_QUERY)
        res = json.dumps(rows.fetchall())
        return parcel_json_response(res)
Esempio n. 6
0
def all_routes():
    """returns all the routes we have!"""
    with std_connection() as conn:
        rows = conn.execute(ALL_PRICES_QUERY)
        res = json.dumps(rows.fetchall())
        return parcel_json_response(res)