Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since the <code>yahoo.finance.option_contracts</code> table is a <a href="http://datatables.org" rel="nofollow">Community Open Data Table</a> you will want to include it as part of the environment for the query. The easiest way to do that is to load up the environment file for <em>all</em> community tables; just like clicking "Show Community Tables" in the YQL console.</p> <p>One would normally do that by specifying an <code>env=...</code> parameter in the YQL query URL, or (as you have done) with a <code>use</code> clause in the query itself.</p> <p>The Python library that you are using lets you pass in the environment file as an argument to <code>execute()</code>.</p> <pre><code>import yql y = yql.Public() query = 'SELECT * FROM yahoo.finance.option_contracts WHERE symbol="SPY"' y.execute(query, env="store://datatables.org/alltableswithkeys") </code></pre> <hr> <p>Here's an example of extending <code>yql.Public</code> to be able to define the default environment on instantiation.</p> <pre><code>class MyYql(yql.Public): def __init__(self, api_key=None, shared_secret=None, httplib2_inst=None, env=None): super(MyYql, self).__init__(api_key, shared_secret, httplib2_inst) self.env = env if env else None def execute(self, query, params=None, **kwargs): kwargs["env"] = kwargs.get("env", self.env) return super(MyYql, self).execute(query, params, **kwargs); </code></pre> <p>It can be used like:</p> <pre><code>y = MyYql(env="store://datatables.org/alltableswithkeys") query = 'SELECT * FROM yahoo.finance.option_contracts WHERE symbol="SPY"' r = y.execute(query) </code></pre> <p>You can still override the <code>env</code> in an individual call to <code>y.execute()</code> if you need to.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload