【发布时间】:2013-03-27 03:56:22
【问题描述】:
我想从 MySQL Workbench 中的 Python 脚本环境执行 SQL 查询。我查看了MySQL Workbench documentation for the grt module 并找到了 executeScript 方法,但我似乎无法使用它来进行查询。
执行此 Python 代码:
import grt
querystring = "select * from Purchases WHERE PurchaseAmount > 600 and PurchaseAmount < 2500"
executeScript(querystring)
产生以下错误消息:
Uncaught exception while executing [filepath]runquery.py:
File "[filepath]runquery.py", line 10, in <module>
executeScript(querystring)
NameError: name 'executeScript' is not defined
我不明白虚拟 grt::ListRef executeScript ( const std::string & sql ) 是什么意思,所以我无法正确格式化我的查询,但是,错误消息似乎表明无论如何,executeScript 方法都不存在。我查看的大多数文档都有格式正确的函数调用示例,但我似乎找不到任何用于 executeScript。
我只想在 MySQL Workbench Python 脚本环境中将我的字符串作为 SQL 查询运行。
谢谢!
我是 Python 和 SQL 的新手,所以请耐心等待。 :)
【问题讨论】:
-
作为用户要求,它必须在 MySQL Workbench Scripting Shell 环境中运行。
标签: python mysql mysql-python mysql-workbench database-administration