问题
For some reason, the following code only returns a dataframe of 10 rows instead of 20 (there are millions of rows in the SQL view). When I viewed the output from print(data2), it showed the first 10 rows as a DataFrame, but the next DataFrame was empty.
import cx_Oracle as cx
import pandas as pd
conn = cx.Connection("username/pwd@server")
data = pd.DataFrame([])
SQL1 = '''SELECT * FROM TABLE_MV where rownum between '''
for i in range(1, 20, 10):
lower = i
upper = i+9
SQL3 = SQL1 + str(lower) + ' and ' + str(upper)
data2 = pd.read_sql(SQL3, conn)
print(data2)
data = data.append(data2)
来源:https://stackoverflow.com/questions/33810228/python-3-4-loop-and-append-why-not-working-with-cx-oracle-and-pandas