Hello I am trying to export a very large SQL table (approx 1.7million rows) into either an excel or csv file, my problem is when I dont specify a chunksize I am getting a memory limit error, I am guessing the data is too large to store in memory. Now that I have passed in a chunksize I am getting a different error.
Error - VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. values = np.array([convert(v) for v in values])
Code:
import pyodbc
import pandas as pd
conn = pyodbc.connect('Driver={SQL Server};'
'Server=servername;'
'Database=DB01;'
'Trusted_Connection=yes;')
sql_query = pd.read_sql_query("select * from calltype", conn, chunksize=1000, dtype=object)
df = pd.DataFrame(sql_query)
df.to_excel(r'C:\Users\user\Documents\BackupTest1.xlsx', index=False)
print("Records Exported")'''