1
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

ZulH
  • 13
  • 3

1 Answers1

0

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)