Python 3.4: Loop and Append: Why Not Working With cx_Oracle and Pandas?

北战南征 提交于 2019-12-11 23:07:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!