如何一起运行mysql Workbench的2个选项? [英] How do I run 2 options of mysql Workbench together?

查看:139
本文介绍了如何一起运行mysql Workbench的2个选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个命令行脚本,

I am trying to write a command-line script which will

  • 打开工作台
  • 连接到指定的数据库
  • 打开一个sql文件
  • 运行
  • 将结果导出到文本文件

我从(

I made use of workbench's guide for command-line guide from (https://dev.mysql.com/doc/workbench/en/wb-command-line-options.html) up to the point of opening the app and connecting to the database. However, I can't combine the options. The options I write after "connect to database" are not read or run properly.

我的问题是如何将它们组合/管道化.

My question is how to combine/pipe them together.

以下命令运行该应用程序并连接到数据库:

The following command runs the app and connects to the database:

"C:\..\MySQLWorkbench.exe" --query testdb

当我添加-脚本C:\ .. \ 23.10.20.sql -打开C:\ .. \ 23.10.20.sql 时,它们没有效果.我只使用空窗口将应用程序连接到数据库.我将它们结合起来:

When I add --script C:\..\23.10.20.sql or --open C:\..\23.10.20.sql they have no effect. I only get the app connected to the database with an empty window. I combine them like:

"C:\..\MySQLWorkbench.exe" --query testdb --script C:\..\23.10.20.sql

将它们组合在一起是正确的方法吗?

Is that the right way to combine them?

通过一起尝试其他两个选项,我确认这不是正确的方法.对于如何一个接一个地运行两个选项,我仍然需要一个答案.

By trying two other options together, I confirmed that this is not the right way. I still need an answer for how to run 2 options one after the other.

我使用的工作台指南中的选项是:

The options from the workbench's guide I use are:

--query [connection|connection_string]:

Connection: Open a named connection.

--model modelfile: open the given EER model file.

--script script: Open the given SQL file in a connection, typically used with the --query parameter.

--run code: Execute the given code using the default language for GRT shell.

--open file: Open the given file at startup. Deprecated, so instead use specific types such as --script or --model.

注意:本指南中有一条注释,表示Windows应使用一个破折号(-),而不是两个破折号(-).尽管我使用的是Windows,但对我而言并非如此.仅当我使用两个破折号时才运行这些选项.短划线,什么也没有发生.

Note: There is a note in this guide saying one dash (-) should be used for Windows instead of two (--). Although I am using Windows, that is not the case for me. The options are only run when I use two dashes. With one dash, nothing happens.

推荐答案

您不能使用WB导出结果,只能打开特定的连接并运行查询或运行python脚本.从原则上讲,可以使用Python导出数据,但这需要花费很多精力.

You cannot use WB to export a result, only to open a specific connection and run a query or to run a python script. In principle it would be possible to use Python to export the data, but this is quite a lot of work for a small effect.

相反,我建议完全不要使用WB,而是直接在脚本中使用MySQL.GUI不太适合进行终端工作.

Instead I recommend not to use WB at all and instead work directly with MySQL in your script. A GUI is not well suited to do terminal work.

这篇关于如何一起运行mysql Workbench的2个选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆