Appending to a Pandas Dataframe From a pd.read_sql Output
How about
for i in orders:
df = df.append(pd.read_sql(querystring, cnxn, params = [i]))
Need to assign the result:
df = df.append(pd.read_sql(querystring, cnxn, params = [i]))
you may try to do it this way:
df = pd.concat([pd.read_sql(querystring, cnxn, params = [i] for i in orders], ignore_index=True)
so you don't need an extra loop ...
alternatively if your orders
list is relatively small, you can select all your rows "in one shot":
querystring = 'select order_number, creation_date from table_name where order_number in ({})'.format(','.join(['?']*len(orders)))
df = pd.read_sql(querystring, cnxn, params=orders)
generated SQL
In [8]: querystring
Out[8]: 'select order_number, creation_date from table_name where order_number in (?,?,?,?)'