我正在尝试重定向在mysqlsh交互环境中执行的语句的输出。
我在OSX上的终端中运行mysqlsh,但在帮助页面中没有找到合适的参数来实现重新路由。通过默认的“管道grep > and_run.txt”重新路由输出是不起作用的,因为mysqlsh环境有它自己的一组接受的命令。
我的命令是:
:$ mysqlsh root@localhost:3306/my_schema
# now the mysqlsh interactive console is open with an active connection to my_schema
mysqlsh> shell.options.set('resultFormat','json')
mysqlsh> session.runSql("SELECT * FROM my_schema.my_table")
# prints the schema as json array - i would like to rerout this output发布于 2020-11-12 20:47:17
实现我的目标的一种方法是不使用mysqlsh的“交互模式”,而是为每个语句打开一个新的连接。
这不是我的首选方法,因为我猜这会为每个命令初始化一个新的会话,但它可以工作。
mysqlsh --uri root@localhost:3306/my_schema --sql --execute "select * from my_table;" --result-format=json/array > my_objects.json我真的很感兴趣/感谢有一个更干净的解决方案。
https://stackoverflow.com/questions/64802702
复制相似问题