[英]How to bulk copy multiple csv files from blob to mutliple sql database tables with data factory
I am trying copy different csv files in blob storage into there very own sql tables(I want to auto create these tables).我正在尝试将 blob 存储中的不同 csv 文件复制到非常自己的 sql 表中(我想自动创建这些表)。 Ive seen alot of questions but I haven't seen any that answer this.我见过很多问题,但我还没有看到任何回答这个问题。
Currently I have a getmetadata function that grabs a list of child items to get the name of the files and a foreach loop but from there I don't know how to have them sent to different tables per file.目前,我有一个 getmetadata function 获取子项列表以获取文件名和一个 foreach 循环,但从那里我不知道如何将它们发送到每个文件的不同表。
Updated:更新:
When I run it for a 2nd time.当我第二次运行它时。 It will add new rows into the table.它会将新行添加到表中。
I created a simple test and it works well.我创建了一个简单的测试,它运行良好。 This is my csv file stored in Azure Data Lake.这是我的 csv 文件存储在 Azure 数据湖中。
Then we can use pipeline to copy this csv file into Azure SQL table(auto create these tables).然后我们可以使用管道将这个 csv 文件复制到 Azure SQL 表中(自动创建这些表)。
GetMetaData1
activity, we can set the dataset of the folder containing csv files在GetMetaData1
活动中,我们可以设置包含 csv 文件的文件夹的数据集 And select First row as header
at the dataset.和 select 数据集中的First row as header
。 2.At ForEach1
activity we can foreach the file list via expression @activity('Get Metadata1').output.childItems
. 2.在ForEach1
活动中,我们可以通过表达式@activity('Get Metadata1').output.childItems
文件列表。
3.Inside ForEach1
activity, we can use Copy data1
activity with the same data source as GetMetaData1
activity. 3.在ForEach1
活动中,我们可以使用与GetMetaData1
活动具有相同数据源的Copy data1
活动。 At source
tab, we can type in dynamic content @item().name
.在source
选项卡中,我们可以输入动态内容@item().name
。 We can use @item().name
to get the file name.我们可以使用@item().name
来获取文件名。
At sink
tab, we should select Auto create table
.在sink
选项卡,我们应该 select Auto create table
。 In the Azure SQL dataset, we should type in schema name
and dynamic content @replace(item().name,'.csv','')
as its table name.在 Azure SQL 数据集中,我们应该输入schema name
和动态内容@replace(item().name,'.csv','')
作为其表名。 Because this information is needed to create a table dynamically.因为动态创建表需要这些信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.