2
votes

I would like to do bulk inserts to my Azure database from Python, but I can't find the documentation for how it's done.

This page says:

The following table summarizes the options for moving data to an Azure SQL Database.

The section linked from that table says:

The steps for the procedure using the Bulk Insert SQL Query are similar to those covered in the sections for moving data from a flat file source to SQL Server on an Azure VM.

And that provides the following query:

BULK INSERT <tablename>
FROM    
'<datafilename>'
WITH 
(
FirstRow=2,
FIELDTERMINATOR =',', --this should be column separator in your data
ROWTERMINATOR ='\n'   --this should be the row separator in your data
)

But presumably that datafile has to live somewhere, but I can't find where in the documentation that it confirms where this data file should live. I can create a csv file and upload it as a blob to Azure storage, but nobody in the last year had an answer for how get it from there to SQL Azure.

How can I bulk insert into SQL Azure?

1
the referenced question just got its answer! Your question however is specific to python, or I am missunderstanding something? If it is OK for you to get your CSV from Blob into SQL DB - check the answer to the referenced question. If you eagerly want to do this by hand with Python, re-write your question.astaykov
I think the data factory approach will be suitable.Wayne Werner

1 Answers

2
votes

SQL Server vNext CTP supports T-SQL commands that load from Azure Blob Storage. This will be available in Azure SQL Database soon so you can use BULK INSERT command from your example to load data from Azure Blob Storage.