you’ll need to learn <aclass="reference external"href="http://www.python.org">Python</a> and <aclass="reference external"href="http://www.sqlalchemy.org">SQLAlchemy</a>.</p>
<spanclass="k">print</span><spanclass="s">u'{0.name}, the {0.genus} Pokemon'</span><spanclass="o">.</span><spanclass="n">format</span><spanclass="p">(</span><spanclass="n">pokemon</span><spanclass="p">)</span>
</pre></div>
</div>
<p>Running this will give you some Bulbasaur info:</p>
<divclass="highlight-none"><divclass="highlight"><pre>Bulbasaur, the Seed Pokemon
</pre></div>
</div>
<divclass="section"id="connecting">
<h2>Connecting<aclass="headerlink"href="#connecting"title="Permalink to this headline">¶</a></h2>
<p>To get information out of the Pokédex, you will need to create a
<ttclass="xref py py-class docutils literal"><spanclass="pre">Session</span></tt>. To do that, use
<aclass="reference internal"href="#pokedex.db.connect"title="pokedex.db.connect"><ttclass="xref py py-func docutils literal"><spanclass="pre">pokedex.db.connect()</span></tt></a>. For simple uses, you don’t need to give it any
arguments: it the database that <ttclass="docutils literal"><spanclass="pre">pokedex</span><spanclass="pre">load</span></tt> fills up by default. If you
need to select another database, give its URI as the first argument.</p>
<p>The object <aclass="reference internal"href="#pokedex.db.connect"title="pokedex.db.connect"><ttclass="xref py py-func docutils literal"><spanclass="pre">connect()</span></tt></a> gives you is actually a
<ttclass="xref py py-class docutils literal"><spanclass="pre">SQLAlchemy</span><spanclass="pre">session</span></tt>, giving you the
<h2>Getting things<aclass="headerlink"href="#getting-things"title="Permalink to this headline">¶</a></h2>
<p>If you know what you want from the pokédex, you can use the
<aclass="reference internal"href="#pokedex.db.util.get"title="pokedex.db.util.get"><ttclass="xref py py-func docutils literal"><spanclass="pre">pokedex.db.util.get()</span></tt></a> function. It looks up a thing in a table, based on
<spanclass="k">print</span><spanclass="s">u'{0.name}, the {0.genus} Pokemon'</span><spanclass="o">.</span><spanclass="n">format</span><spanclass="p">(</span><spanclass="n">pokemon</span><spanclass="p">)</span>
<divclass="highlight-none"><divclass="highlight"><pre>Eevee, the Evolution Pokemon
Ho-Oh, the Rainbow Pokemon
Diglett, the Mole Pokemon
Great Ball: $600
Potion: $300
Fresh Water: $200
</pre></div>
</div>
</div>
<divclass="section"id="querying">
<h2>Querying<aclass="headerlink"href="#querying"title="Permalink to this headline">¶</a></h2>
<p>So, how do you get data from the session? You use the session’s
<ttclass="xref py py-meth docutils literal"><spanclass="pre">query()</span></tt> method, and give it a pokédex
Table as an argument. This will give you a <ttclass="xref py py-class docutils literal"><spanclass="pre">SQLAlchemy</span><spanclass="pre">query</span></tt>.</p>
<divclass="section"id="ordering">
<h3>Ordering<aclass="headerlink"href="#ordering"title="Permalink to this headline">¶</a></h3>
<p>As always with SQL, you should not rely on query results being in some
particular order – unless you have ordered the query first. This means that
you’ll want to sort just about every query you will make.</p>
<p>For example, you can get a list of all pokémon species, sorted by their
<ttclass="xref py py-attr docutils literal"><spanclass="pre">id</span></tt>, like so:</p>
<divclass="highlight-none"><divclass="highlight"><pre>The most powerful Grass-type moves:
Petal Dance (120)
Power Whip (120)
Seed Flare (120)
SolarBeam (120)
Wood Hammer (120)
Leaf Storm (140)
Frenzy Plant (150)
</pre></div>
</div>
<p>That concludes our brief tutorial.
If you need to do more, consult the <aclass="reference external"href="http://www.sqlalchemy.org/docs/orm/tutorial.html">SQLAlchemy documentation</a>.</p>
</div>
</div>
<divclass="section"id="api-documentation">
<h2>API documentation<aclass="headerlink"href="#api-documentation"title="Permalink to this headline">¶</a></h2>
<dlclass="function">
<dtid="pokedex.db.connect">
<ttclass="descclassname">pokedex.db.</tt><ttclass="descname">connect</tt><big>(</big><em>uri=None</em>, <em>session_args={}</em>, <em>engine_args={}</em>, <em>engine_prefix=''</em><big>)</big><aclass="headerlink"href="#pokedex.db.connect"title="Permalink to this definition">¶</a></dt>
<dd><p>Connects to the requested URI. Returns a session object.</p>
<p>With the URI omitted, attempts to connect to a default SQLite database
contained within the package directory.</p>
<p>Calling this function also binds the metadata object to the created engine.</p>
<p>See <ttclass="xref py py-class docutils literal"><spanclass="pre">sqlalchemy.orm.session.Session</span></tt> for more documentation on the
returned object.</p>
</dd></dl>
<dlclass="function">
<dtid="pokedex.db.util.get">
<ttclass="descclassname">pokedex.db.util.</tt><ttclass="descname">get</tt><big>(</big><em>session</em>, <em>table</em>, <em>identifier=None</em>, <em>name=None</em>, <em>id=None</em>, <em>language=None</em><big>)</big><aclass="headerlink"href="#pokedex.db.util.get"title="Permalink to this definition">¶</a></dt>
<dd><p>Get one object from the database.</p>
<p>session: The session to use (from pokedex.db.connect())
table: The table to select from (such as pokedex.db.tables.Move)</p>
<p>identifier: Identifier of the object
name: The name of the object
id: The ID number of the object</p>
<p>language: A Language to use for name and form_name</p>
<p>All conditions must match, so it’s not a good idea to specify more than one
of identifier/name/id at once.</p>
<p>If zero or more than one objects matching the criteria are found, the