import sqlite3, json, gzip
def dbf(day): return '/tmp/rl/d%s.db'%day[-2:] if day[5:7]=='09' and int(day[-2:])<=28 else '/tmp/rl/d%sx.db'%day[-2:]
def pool_of(tok, day):
    for l in gzip.open('/tmp/rl/rows_%s.jsonl.gz'%day,'rt'):
        if tok in l:
            o=json.loads(l)
            if o['tok']==tok:
                c=sqlite3.connect(dbf(day)); return c.execute('select pool from pools where rowid=?',(o['mp'],)).fetchone()[0]
