sql - Python pandas read_sql returns generator object -
i pulling data oracle db using pyodbc , pandas read_sql.
i see no errors when enter line
df = pd.read_sql(sql_str,cnxn,chunksize=10)
but when try see
df
i error
<generator object _query_iterator @ 0x092d40f8>
my search error means or causing yielded no satisfactory answers.
the reason using chunksize have oracle db table 60 million rows, , plan download in bits , put them together, here: how create large pandas dataframe sql query without running out of memory?
as explanation of chunksize
says, when specified, returns iterator chunksize number of rows include in each chunk.
can iterate through result , each chunk:
for chunk in pd.read_sql_query(sql_str, engine, chunksize=10): do_something_with(chunk)
typically can process chunk , add list, , after loop concat processed chunks in list together.
also see docs on sql querying: http://pandas.pydata.org/pandas-docs/stable/io.html#querying example.
Comments
Post a Comment