Reputation: 13
for i in Com_Tables:
try:
frames = [pd.read_sql(f"SELECT * FROM {i}", conn).assign(ComId_Code = i)]
except:
pass
finally:
dfxilnex = pd.concat(frames)
i am expecting output to concat all data from each item in list however the result is showing only data for last item in list
Upvotes: 1
Views: 41
Reputation: 11522
You are not appending anything so there is nothing to concatnate. try this:
frames = []
for i in Com_Tables:
try:
frames.append(pd.read_sql(f"SELECT * FROM {i}", conn).assign(ComId_Code = i))
except:
pass
dfxilnex = pd.concat(frames)
Upvotes: 0