import pandas as pd
dbcon = ... # whatever
with open("out.csv", "w") as fh:
chunks = pd.read_sql_query("SELECT * FROM table_name", dbcon,chunksize=10000)
next(chunks).to_csv(fh, index=False) # write the first chunk with the column names,
# but ignore the index (which will be screwed up anyway due to the chunking)
for chunk in chunks:
chunk.to_csv(fh, index=False, header=False) # skip the column names from now on
в приведенном выше коде, как я могу получить количество строк в переменной, которые записываются в CSV-файл?