def _getForcings(e, dbname, ptable, rtables, name, dt0, dt1):
    db = dbio.connect(dbname)
    cur = db.cursor()
    data = {}
    for v in ['precip', 'tmax', 'tmin', 'wind']:
        temptable = ''.join(random.SystemRandom().choice(
            string.ascii_letters) for _ in range(8))
        sql = "create table {7} as (with f as (select gid,st_worldtorastercoordx(rast,geom) as xf,st_worldtorastercoordy(rast,geom) as yf,rid as ftile from {6}.{0},{1}.basin where fdate=date'{2}-{3}-{4}' and st_intersects(rast,geom)) select c.gid,xf,yf,x,y,ftile as tile from f inner join precip.{5}_iri_xy as c on c.gid=f.gid)".format(
            rtables[v], name, dt0.year, dt0.month, dt0.day, ptable, v, temptable)
        cur.execute(sql)
        db.commit()
        cur.execute("create index {0}_r on {0}(tile)".format(temptable))
        db.commit()
        sql = "select gid,fdate,st_value(rast,xf,yf) from {6}.{0},{7} as xy inner join iri_years as i on xy.x=i.x and xy.y=i.y where ens={2} and rid=tile and fdate>=date(concat_ws('-',yr,'{3}-{4}')) and fdate<=(date(concat_ws('-',yr,'{3}-{4}'))+interval'{5} days') order by gid,fdate".format(
            rtables[v], ptable, e + 1, dt0.month, dt0.day, (dt1 - dt0).days, v, temptable)
        cur.execute(sql)
        data[v] = cur.fetchall()
        cur.execute("drop table {0}".format(temptable))
        db.commit()
    cur.close()
    db.close()
    return data
Find resources given a datastore query expression dict.
dataset/ETHPy150Open nasa/RHEAS/src/datasets/iri.py/_getForcings--crossover with--dataset/ETHPy150Open ooici/pyon/pyon/datastore/postgresql/datastore.py/PostgresPyonDataStore.find_by_query