简体   繁体   English

如何使用数据工厂将多个 csv 文件从 blob 批量复制到多个 sql 数据库表

[英]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 表中(自动创建这些表)。

  1. At GetMetaData1 activity, we can set the dataset of the folder containing csv filesGetMetaData1活动中,我们可以设置包含 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来获取文件名。 在此处输入图像描述

  1. 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.因为动态创建表需要这些信息。 在此处输入图像描述

  2. The debug result is as follows:调试结果如下:
    在此处输入图像描述 在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 复制信息CSV文件到SQL数据库(Azure数据工厂) - Copy information CSV Files to SQL Database (Azure Data Factory) 如何在没有 Azure 数据工厂的情况下将 csv 文件从 blob 存储加载到 azure sql 数据库 - How to load csv file from blob storage to azure sql database without Azure Data Factory 数据工厂:从Blob复制到SQL后如何执行查询? - Data factory: how to execute query after copy from blob to SQL? Azure 数据工厂 - 从 Blob 批量导入 Azure SQL - Azure Data Factory - Bulk Import from Blob to Azure SQL 如何从Azure数据工厂中的azure blob存储中获取某些数据,并将目标作为SQL数据库执行复制活动? - How to get just certain data from azure blob storage in Azure Data Factory performing copy activity with destination as SQL database? 有条件将Blob数据复制到Azure Data Factory中的Sql数据库 - Copy Blob Data To Sql Database in Azure Data Factory with Conditions 将 CSV 从 Blob 存储批量加载到 SQL 数据库 - Bulk Loading CSV From Blob Storage to SQL Database 如何使用 Odata 链接服务将文件从共享点复制到 blob 存储 azure 数据工厂 v2 - How to copy files from sharepoint into blob storage azure data factory v2 using Odata linked service Azure 数据工厂:如何在复制或导入期间重命名 Blob csv 或 Blob 存储中的文本文件? - Azure Data Factory: How to rename blob csv or text file in blob storage during copy or import? 如何使用数据工厂将数据从 Azure Blob 存储增量加载到 Azure SQL 数据库? - How to incrementally load data from Azure Blob storage to Azure SQL Database using Data Factory?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM