import sqlite3


def getStations(options, type):
    """Query stations by specific type ('GHCND', 'ASOS', 'COOP', 'USAF-WBAN')
    """
    conn = sqlite3.connect(options.database)
    c = conn.cursor()
    if type == "ALL":
        c.execute("select rowid, id, name, lat, lon from stations")
    else:
        c.execute("select rowid, id, name, lat, lon from stations where type = ?",(type,))
    stations = []
    for r in c:
        stations.append(r)
    conn.close()
    return stations