Import Wizard导入向导

Posted on: 16/09/2020 (last updated: 09/03/2022) by Dakota Karlsson

Studio 3T’s Import Wizard lets you import JSON, CSV, BSON/mongodump, SQL, and another collection to MongoDB.Studio 3T的导入向导允许您将JSON、CSV、BSON/mongodump、SQL和其他集合导入MongoDB。

To follow along with this video, you’ll want to download the customers.json file mentioned in the introduction.要继续观看本视频,您需要下载介绍中提到的customers.json文件。

Download Studio 3T here to access Import Wizard and skip ahead to your format:此处下载Studio 3T以访问导入向导,并跳到您的格式:

Looking to export, not import? 想导出而不是导入?Use the Export Wizard instead to export MongoDB to CSV, JSON, BSON/mongodump, SQL, and to another collection.使用导出向导将MongoDB导出为CSV、JSON、BSON/mongodump、SQL和其他集合。

Basics基础

After successfully connecting to a MongoDB database, open the Import Wizard by clicking on Import in the Global Toolbar.成功连接到MongoDB数据库后,单击“全局”工具栏中的“导入”打开“导入向导”。

Alternatively, right-click on any server, database, or collection in the Connection Tree and choose Import (Collections, Data).或者,右键单击连接树中的任何服务器、数据库或集合,然后选择“导入(集合、数据)”。

Or right-click anywhere on a Result tab (Collection Tab, SQL Query, IntelliShell), or any input or output panel in Aggregation Editor and choose Import.或者右键单击“结果”选项卡(“集合”选项卡、“SQL查询”、“IntelliShell”)上的任意位置,或“聚合编辑器”中的任何输入或输出面板,然后选择“导入”。

From here, choose one of the supported import formats:从这里,选择一种受支持的导入格式:

The Operations window on the bottom-left side tracks the progress of your import.左下方的“操作”窗口跟踪导入的进度。

Automate and schedule imports as tasks将导入作为任务进行自动化和计划

Import Wizard integrates with Tasks and Task Scheduler, which let you save recurring imports as tasks. You can, of course, also run all imports immediately by clicking on Execute.导入向导与任务和任务调度器集成,允许您将定期导入保存为任务。当然,您也可以通过单击“执行”立即运行所有导入。

To save an import as a task, click on Save task (as). 要将导入另存为任务,请单击“任务另存为”。Name the task, then click OK.命名任务,然后单击“确定”。

This saves the task in the Task Viewer, from which you can choose to schedule, unschedule, edit, clone, delete, add, and execute tasks.这会将任务保存在任务查看器中,从中可以选择计划、取消计划、编辑、克隆、删除、添加和执行任务。

Learn more about Tasks and Tasks Scheduler.了解有关任务和任务调度器的更多信息。

Import CSV to MongoDB (e.g. Excel)将CSV导入MongoDB(例如Excel)

https://player.vimeo.com/video/681934019

Open the Import Wizard. 打开“导入向导”Then, choose CSV as the import format.然后,选择“CSV”作为导入格式。

This will open up the two sub-tabs, Source options and Target options.这将打开两个子选项卡,“源选项”和“目标选项”。

Import from clipboard从剪贴板导入

If you already have copied data, click on Import from Clipboard and Studio 3T will automatically show a preview of the detected rows.如果已经复制了数据,请单击“从剪贴板导入”,Studio 3T将自动显示检测到的行的预览。

Update the settings (e.g. delimiter, text qualifier) in the top-right to configure your import.更新右上角的设置(如分隔符、文本限定符)以配置导入。

Import from CSV file从CSV文件导入

Click on the folder icon and locate the CSV file to be imported.单击文件夹图标,找到要导入的CSV文件。

Same as above, a preview will appear. 如上所述,将出现预览。Configure the other settings as needed.根据需要配置其他设置。

Click on the Target options tab to further configure the CSV import.单击“目标选项”选项卡以进一步配置CSV导入。

If the target collection already exists如果目标集合已经存在, the imported rows will be added to that collection. ,导入的行将添加到该集合中。If the target collection doesn’t exist如果目标集合不存在, Studio 3T will automatically create one with the same name.,Studio 3T将自动创建一个同名的。

Choose which fields to import by checking/unchecking the boxes in the Import options view, and double-check that all looks good in the JSON output preview.通过选中/取消选中“导入选项”视图中的框来选择要导入的字段,并在“JSON输出预览”中仔细检查所有字段是否良好。

Once done, you can save the export as a task, which you can run on-demand or schedule for later, or execute the task immediately.完成后,您可以“将导出保存为任务”,可以按需运行或计划稍后运行,也可以立即“执行”该任务。

Ready to import? 准备好进口了吗?Download the latest Studio 3T version here.这里下载最新的Studio 3T版本。

Supported date formats支持的日期格式

CSV import supports eight date formats:CSV导入支持八种日期格式

The date format XXX supports all order variations of the year, month, and day fields, as well as three separators: “-“, “/” and “.”日期格式XXX支持年、月和日字段的所有订单变化,以及三个分隔符:“-”、“/”和“.”

Both ISO and Locale formats accept their respective variations like date only, date with short or long time, etc.ISO和Locale格式都接受各自的变化,如仅日期、短时间或长时间的日期等。

Upon CSV import, Studio 3T will try to detect a suitable date format for all the values of a column and will automatically use one based on the following criteria:导入CSV后,Studio 3T将尝试为列的所有值检测合适的日期格式,并将根据以下标准自动使用一种格式:

But of course, as with all data types, the selection can always be overridden.但当然,与所有数据类型一样,选择总是可以被覆盖的。

Import JSON to MongoDB将JSON导入MongoDB

https://player.vimeo.com/video/681941709

Open the Import Wizard. 打开“导入向导”Then, choose JSON as the import format and click OK.然后,选择“JSON”作为导入格式,然后单击“确定”。

Click on + to add JSON source documents, to remove them, or the clipboard icon to paste JSON data from the clipboard.单击“+”添加JSON源文档,单击“-”删除它们,或单击“剪贴板图标”从剪贴板粘贴JSON数据。

Here we will add the JSON source document, Rainfall-Data.这里我们将添加JSON源文件“Rainfall-Data”。

Under the Target Database and Target Collection, double-click on a cell to type in the target database or collection.在“目标数据库”和“目标集合”下,双击单元格以键入目标数据库或集合。

Under the Insertion Mode column, double-click on a cell to choose one of the insertion modes from the drop-down menu.在“插入模式”列下,双击单元格,从下拉菜单中选择一种插入模式。

Click on Execute to run the import. 单击“执行”以运行导入。Alternatively, choose Save task or Save task as… to automate the task.或者,选择“保存任务”或“将任务另存为”以自动执行任务

Download Studio 3T to start your JSON import.下载Studio 3T以开始JSON导入。

Import BSON/mongodump to MongoDB将BSON/mongodump导入MongoDB

Open the Import Wizard. 打开“导入向导”Then, select BSON – mongodump folder or BSON – mongodump archive as the import format.然后,选择“BSON-mongodump文件夹”或“BSON-mongodump存档”作为导入格式。

For both types, you will need to configure a ‘mongorestore’ executable under Preferences > MongoDB tools.对于这两种类型,您都需要在“首选项”>“MongoDB工具”下配置“mongorestore”可执行文件。

Click on the folder icon and choose the root mongodump folder to be imported. 单击文件夹图标并选择要导入的“根”mongodump文件夹。If the folder is valid, the available databases and collections will auto-populate the Import sources section.如果文件夹有效,可用的数据库和集合将自动填充“导入源”部分。

Check or uncheck the collections to include or exclude them in the import.选中或取消选中集合以在导入中包括或排除它们。

Under the BSON options tab, check or uncheck other configuration options as you see fit.在“BSON选项”选项卡下,根据需要选中或取消选中其他配置选项。

When ready, click on Execute to run the import. 准备好后,单击“执行”以运行导入。Alternatively, choose Save task or Save task as to schedule the task.或者,选择“保存任务”或“将任务另存为”来调度任务

Import SQL & Migration to MongoDB导入SQL并迁移到MongoDB

https://player.vimeo.com/video/681937311

https://player.vimeo.com/video/681931136

Import Wizard导入向导 imports a single SQL table to a single MongoDB collection at a time.一次将单个SQL表导入单个MongoDB集合。

If you need to import entire SQL databases or multiple SQL tables to a single MongoDB collection, then SQL to MongoDB Migration is the right feature for you.如果需要将整个SQL数据库或多个SQL表导入到单个MongoDB集合中,那么“SQL到MongoDB的迁移”正适合您。

Check out these articles for more detail:查看以下文章了解更多详细信息:

Choose SQL Database as the import format which will open the SQL Import tab.选择“SQL数据库”作为导入格式,将打开“SQL导入”选项卡。

To define the source SQL connection, click Click here to connect to a server which will open the SQL Connection Manager.要定义源SQL连接,单击“点击此处连接到服务器”将打开“SQL连接管理器”。

Most users will need to create a new SQL connection.大多数用户将需要创建一个新的SQL连接。

Click on New Connection in the toolbar and fill out the Server and SSH Tunnel tabs with the details needed. 单击工具栏中的“新建连接”,并用所需的详细信息填写“服务器”和“SSH Tunnel”选项卡。Click Save. 单击“保存”。Then click OK. 然后点击“确定”。For future imports, you can simply choose the saved connection from the list.对于将来的导入,只需从列表中选择保存的连接即可。

Next, choose the source SQL table by clicking on Click here to select a table. 接下来,通过单击“点击此处以选择表”来选择源SQL表。This will display a list of all SQL tables in your database.这将显示数据库中所有SQL表的列表。

Type to filter or simply choose the source table from the list.键入以筛选,或从列表中选择源表。

Next, define the target MongoDB database and target MongoDB collection by typing their names, or dragging and dropping them from the Connection Tree.接下来,通过键入“目标MongoDB数据库”和“目标MongoDB集合”的名称,或从连接树中拖放它们来定义它们。

If the target collection already exists, the imported rows will be added to that collection. 如果目标集合已经存在,则导入的行将添加到该集合中。If the target collection doesn’t exist, Studio 3T will automatically create one with the same name.如果目标集合不存在,Studio 3T将自动创建一个同名集合。

Choose an insertion mode from the dropdown menu.从下拉菜单中选择“插入模式”。

Next, check (or uncheck) fields in the Import options section to include (or exclude) them in the import.接下来,选中(或取消选中)“导入选项”部分中的字段,以便在导入中包括(或排除)它们。

You can double-click on any cell under Field Name or Mongo Type columns to update field names and field types. 可以双击“字段名”或“Mongo类型”列下的任何单元格来更新字段名和字段类型。The resulting JSON output preview is shown on the right.生成的“JSON输出预览”显示在右侧。

Additional settings you can configure:您可以配置的其他设置:

Once done, click on Execute to run the import or choose Save task or Save task as to automate the import.完成后,单击“执行”以运行导入,或选择“保存任务”或“将任务另存为”以自动导入

SQL Import to MongoDB is a Pro and Ultimate feature. SQL导入MongoDB是一项专业且终极的功能。Learn more about the different Studio 3T editions.了解有关不同Studio 3T版本的更多信息。

Studio 3T supports all the major SQL databases: Oracle (Ultimate version only), Microsoft SQL Server, MySQL, PostgreSQL, IBM DB2 (Ultimate version only), and Sybase (Ultimate version only).Studio 3T支持所有主要的SQL数据库:Oracle(仅限最终版本)、Microsoft SQL Server、MySQL、PostgreSQL、IBM DB2(仅限最终版本)和Sybase(仅限最终版本)。

Import another collection导入另一个集合

Looking to copy MongoDB collections to another database? Here’s a quicker way.是否希望将MongoDB集合复制到另一个数据库?这里有一个更快的方法。

Open the Import Wizard and select Another collection as the import format. 打开导入向导,选择“另一个集合”作为导入格式。This will open the Collection Import tab.这将打开“集合导入”选项卡。

Define the Target database by typing its name and choosing it from the auto-detected list. 通过键入“目标数据库”的名称并从自动检测列表中选择它来定义目标数据库。Alternatively, drag and drop it from the Connection Tree.或者,将其从连接树中拖放。

Do the same for Target collection. 对“目标集合”执行同样的操作。Then, choose an insertion method from the dropdown menu.然后,从下拉菜单中选择“插入方法”。

If the target collection already exists, the imported rows will be added to that collection. 如果目标集合已经存在,则导入的行将添加到该集合中。If the target collection doesn’t exist, Studio 3T will automatically create one with the same name.如果目标集合不存在,Studio 3T将自动创建一个同名集合。

Now that we’ve configured the target database, let’s define the source database.现在我们已经配置了目标数据库,让我们定义源数据库。

Click on Connect to source and choose the source MongoDB connection from the Connection Manager. 单击“连接到源”并从“连接管理器”中选择源MongoDB连接。Click Connect.单击“连接”。

Next, choose the source collection from the tree. 接下来,从树中选择“源集合”。This is the collection that will be copied and pasted into your target collection.这是将被复制并粘贴到目标集合中的集合。

Click Execute to run the import, or save the import as a task by clicking Save task (as).单击“执行”以运行导入,或通过单击“保存任务”(另存为)将导入另存为任务。


Want other time-saving features? Make sure to check these out:想要其他省时功能吗?请务必查看以下内容: