title: How to execute an SQL query with Python script in MySQL Workbench
body: <p>I want to execute SQL queries from the Python script environment in MySQL Workbench. I looked at the <a href="http://mysqlworkbench.org/workbench/doc/globals/classdb__query___editor.html#ad52e9a8a82cbe53845b4b820e4897ae8" rel="nofollow">MySQL Workbench documentation for the grt module</a> and found the executeScript method but I can't seem to use it to make queries.</p>
  
  <p>Executing this Python code:</p>
  
  <pre><code>import grt
  
  querystring = "select * from Purchases WHERE PurchaseAmount &gt; 600 and PurchaseAmount &lt; 2500"
  executeScript(querystring)
  </code></pre>
  
  <p>produces the following error message:</p>
  
  <pre><code>Uncaught exception while executing [filepath]runquery.py:
  
  File "[filepath]runquery.py", line 10, in &lt;module&gt;
  
  executeScript(querystring)
  
  NameError: name 'executeScript' is not defined
  </code></pre>
  
  <p>I don't understand what virtual <em>grt::ListRef executeScript (   const std::string &amp;     sql  )</em> means so I can't format my query properly, however, the error message seems to indicate that the executeScript method doesn't exist anyway. Most documentation I look at has examples of correctly-formatted function calls but I can't seem to find any for executeScript.</p>
  
  <p>All I want to do is literally run my string as an SQL query within the MySQL Workbench Python scripting environment.</p>
  
  <p>Thank you!</p>
  
  <p>I am new to Python and SQL so please be patient. :)</p>