I use sp_execute_external_script function to read and insert data into sql server and everything works, but I don't know how to use it to insert data using chunks.
the script that loads the data:
declare @scr nvarchar(max) =
N'
import pandas as pd
OutputDataSet = pd.read_csv(r"C:\panda\test3.zip", names = ["PersonID", "FullName", "PreferredName", "SearchName", "IsPermittedToLogon", "Age"], header = 0, compression = "zip")
'
INSERT INTO [PANDA].[dbo].[tbl_sample_csv]
EXEC sp_execute_external_script
@language = N'Python',
@script = @scr
What I would like to do is load the printed data in chunks to [PANDA].[dbo].[tbl_sample_csv] to reduce the ram consumption on the server:
declare @scr nvarchar(max) =
N'
import pandas as pd
for chunks in pd.read_csv(r"C:\panda\test3.zip", names = ["PersonID", "FullName", "PreferredName", "SearchName", "IsPermittedToLogon", "Age"], header = 0, compression = "zip", chunksize=500000):
print(chunks)
'
EXEC sp_execute_external_script
@language = N'Python',
@script = @scr
Has anyone had a similar problem and can give me some tips? I tried with @input_data_1 but I don't know how to pass sql object to python