cursor.execute(sql)
return cursor.fetchall()

def using_sqlite_dates():
    sql = """
        SELECT p.price, t.date
        FROM ( SELECT date from dates ) t
        LEFT JOIN price p
        ON p.date = t.date
    """
cursor.execute(sql)
return cursor.fetchall()

def using_python_dict():
    cursor.execute(
        """
        SELECT date, price
        FROM price
        WHERE date <= ?
            AND date >= ?
            """
        , (max(dates), min(dates)))
result = dict(cursor.fetchall())
result = [(result.get(d, None), d) for d in dates]
return result
N = 500
m = 10
omit = random.sample(list(range(N)), m)
dates = [(datetime.date(2000, 1, 1) + datetime.timedelta(days=i)) for i in
    range(N)]
rows = [(d, random.random()) for i, d in enumerate(dates) if i not in omit]
Query Sqlite for multiple arguments at once and handling missing values