I'd like to search for multiple pattern with one query, for example :
select * from rates where host IN ('host1', 'host2') and epoch<1376492112 and epoch>137649200;
I don't know how to make it possible with python, keeping in mind that I can have one or more hosts to search.
It would look like this :
t = (','.join(hosts), fromdate, todate,)
db = 'db.sqlite'
conn = sqlite3.connect(db)
c = conn.cursor()
c.execute('SELECT host, ops FROM rates WHERE host IN (?) AND epoch<? AND epoch>?', t)
rawresults = c.fetchall()
conn.close()
But as you can guess this won't work if I have several hosts (there will be a shifting, and my second host will be used as the epoch variable in the sql request)
Any idea ?