<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Another Step-by-Step SqlAlchemy Tutorial (part 1 of 2)</title>
	<atom:link href="http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/</link>
	<description>Python Programming from the Frontlines</description>
	<lastBuildDate>Sun, 05 Feb 2012 20:38:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/comment-page-1/#comment-21485</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 20 Aug 2010 15:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=487#comment-21485</guid>
		<description>Hi,

Personally, I tend to use the session interface in SqlAlchemy to do my queries: http://www.sqlalchemy.org/docs/ormtutorial.html

Normally, to do a select all, you&#039;d do something like this:

&lt;code&gt;

from sqlalchemy.orm import sessionmaker
Session = sessionmaker()
session = Session()

# Do a select *
result = session.query(TableClassName).all()

&lt;/code&gt;

But yes, I do need to write another tutorial on SqlAlchemy that goes over existing database interfacing, among other things. Thanks for the readership!

- Mike</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Personally, I tend to use the session interface in SqlAlchemy to do my queries: <a href="http://www.sqlalchemy.org/docs/ormtutorial.html" rel="nofollow">http://www.sqlalchemy.org/docs/ormtutorial.html</a></p>
<p>Normally, to do a select all, you&#8217;d do something like this:</p>
<p><code></p>
<p>from sqlalchemy.orm import sessionmaker<br />
Session = sessionmaker()<br />
session = Session()</p>
<p># Do a select *<br />
result = session.query(TableClassName).all()</p>
<p></code></p>
<p>But yes, I do need to write another tutorial on SqlAlchemy that goes over existing database interfacing, among other things. Thanks for the readership!</p>
<p>- Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deltones</title>
		<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/comment-page-1/#comment-21480</link>
		<dc:creator>Deltones</dc:creator>
		<pubDate>Fri, 20 Aug 2010 15:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=487#comment-21480</guid>
		<description>Mike,

Starting to learn SQLAlchemy. About your comment that you can connect to previously created tables, I noticed that every SQLAlchemy I found so far has an example like you wrote, ie create the table and then go from there, but none where an already existing table on an Oracle database for example is used.

My question is: Do I need to create the metadata for an existing table I want to use in order to be able to select the data from it? Here&#039;s a test script I tried to run with an already existing table:

----------
#!/usr/bin/env python

from sqlalchemy import create_engine
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
from sqlalchemy.sql import select

engine = create_engine(&#039;oracle://myconnectioninfohere&#039;, echo=True)

metadata = MetaData()

myTable = Table(&#039;microschargement&#039;, metadata, autoload_with=engine)

conn = engine.connect()

mySelect = select([myTable])
print mySelect

myDataSet = conn.execute(mySelect)

for row in myDataSet:
    print row
----------

It doesn&#039;t work. The result from the &quot;print mySelect&quot; statement gives me:

&quot;select from microschargement&quot;

and I expected:

&quot;select * from microschargement&quot;

Of course, when I reach the &quot;execute(mySelect) statement, the program crashes.

Could you add a little bit of info on how to access the data from an already created table? It would be much appreciated.</description>
		<content:encoded><![CDATA[<p>Mike,</p>
<p>Starting to learn SQLAlchemy. About your comment that you can connect to previously created tables, I noticed that every SQLAlchemy I found so far has an example like you wrote, ie create the table and then go from there, but none where an already existing table on an Oracle database for example is used.</p>
<p>My question is: Do I need to create the metadata for an existing table I want to use in order to be able to select the data from it? Here&#8217;s a test script I tried to run with an already existing table:</p>
<p>&#8212;&#8212;&#8212;-<br />
#!/usr/bin/env python</p>
<p>from sqlalchemy import create_engine<br />
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey<br />
from sqlalchemy.sql import select</p>
<p>engine = create_engine(&#8216;oracle://myconnectioninfohere&#8217;, echo=True)</p>
<p>metadata = MetaData()</p>
<p>myTable = Table(&#8216;microschargement&#8217;, metadata, autoload_with=engine)</p>
<p>conn = engine.connect()</p>
<p>mySelect = select([myTable])<br />
print mySelect</p>
<p>myDataSet = conn.execute(mySelect)</p>
<p>for row in myDataSet:<br />
    print row<br />
&#8212;&#8212;&#8212;-</p>
<p>It doesn&#8217;t work. The result from the &#8220;print mySelect&#8221; statement gives me:</p>
<p>&#8220;select from microschargement&#8221;</p>
<p>and I expected:</p>
<p>&#8220;select * from microschargement&#8221;</p>
<p>Of course, when I reach the &#8220;execute(mySelect) statement, the program crashes.</p>
<p>Could you add a little bit of info on how to access the data from an already created table? It would be much appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: driscollis</title>
		<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/comment-page-1/#comment-21233</link>
		<dc:creator>driscollis</dc:creator>
		<pubDate>Thu, 29 Jul 2010 17:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=487#comment-21233</guid>
		<description>No. You can use SqlAlchemy to connect to previously created tables too!&lt;br&gt;&lt;br&gt;- Mike</description>
		<content:encoded><![CDATA[<p>No. You can use SqlAlchemy to connect to previously created tables too!</p>
<p>- Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guest</title>
		<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/comment-page-1/#comment-21232</link>
		<dc:creator>Guest</dc:creator>
		<pubDate>Thu, 29 Jul 2010 12:38:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=487#comment-21232</guid>
		<description>good tutorial. I have something confused&lt;br&gt; is it means i have to use sqlalchemy to create table ?</description>
		<content:encoded><![CDATA[<p>good tutorial. I have something confused<br /> is it means i have to use sqlalchemy to create table ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Digimasterdoug</title>
		<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/comment-page-1/#comment-20975</link>
		<dc:creator>Digimasterdoug</dc:creator>
		<pubDate>Tue, 15 Jun 2010 08:06:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=487#comment-20975</guid>
		<description>you sir, are a godsend.</description>
		<content:encoded><![CDATA[<p>you sir, are a godsend.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tosa</title>
		<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/comment-page-1/#comment-20571</link>
		<dc:creator>tosa</dc:creator>
		<pubDate>Fri, 16 Apr 2010 09:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=487#comment-20571</guid>
		<description>thx for the tutorial, &lt;br&gt;how to create table with select function with sqlalchemy in python??&lt;br&gt;thanks before..</description>
		<content:encoded><![CDATA[<p>thx for the tutorial, <br />how to create table with select function with sqlalchemy in python??<br />thanks before..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Akira</title>
		<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/comment-page-1/#comment-20039</link>
		<dc:creator>Akira</dc:creator>
		<pubDate>Thu, 11 Mar 2010 15:33:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=487#comment-20039</guid>
		<description>Mike,

Thank you for the tutorial.

I&#039;ve got &quot;ArgumentError: columns argument to select() must be a Python list or other iterable
&quot; while executing &quot;select(and_(users_table.c.name==&quot;Martha&quot;, users_table.c.age &lt; 25))&quot;

If I replace it by &quot;select([users_table], and_(users_table.c.name==&quot;Martha&quot;, users_table.c.age &lt; 25))&quot; then it works fine.</description>
		<content:encoded><![CDATA[<p>Mike,</p>
<p>Thank you for the tutorial.</p>
<p>I&#8217;ve got &#8220;ArgumentError: columns argument to select() must be a Python list or other iterable<br />
&#8221; while executing &#8220;select(and_(users_table.c.name==&#8221;Martha&#8221;, users_table.c.age &lt; 25))&quot;</p>
<p>If I replace it by &quot;select([users_table], and_(users_table.c.name==&quot;Martha&quot;, users_table.c.age &lt; 25))&quot; then it works fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Akira</title>
		<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/comment-page-1/#comment-22818</link>
		<dc:creator>Akira</dc:creator>
		<pubDate>Thu, 11 Mar 2010 15:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=487#comment-22818</guid>
		<description>Mike,

Thank you for the tutorial.

I&#039;ve got &quot;ArgumentError: columns argument to select() must be a Python list or other iterable
&quot; while executing &quot;select(and_(users_table.c.name==&quot;Martha&quot;, users_table.c.age &lt; 25))&quot;

If I replace it by &quot;select([users_table], and_(users_table.c.name==&quot;Martha&quot;, users_table.c.age &lt; 25))&quot; then it works fine.</description>
		<content:encoded><![CDATA[<p>Mike,</p>
<p>Thank you for the tutorial.</p>
<p>I&#8217;ve got &#8220;ArgumentError: columns argument to select() must be a Python list or other iterable<br />
&#8221; while executing &#8220;select(and_(users_table.c.name==&#8221;Martha&#8221;, users_table.c.age &lt; 25))&quot;</p>
<p>If I replace it by &quot;select([users_table], and_(users_table.c.name==&quot;Martha&quot;, users_table.c.age &lt; 25))&quot; then it works fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/comment-page-1/#comment-16969</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 05 Feb 2010 19:21:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=487#comment-16969</guid>
		<description>@ jotr,

I changed the query in this post to use an equality check rather than using &quot;like&quot; since that seemed to be causing me issues.

- Mike</description>
		<content:encoded><![CDATA[<p>@ jotr,</p>
<p>I changed the query in this post to use an equality check rather than using &#8220;like&#8221; since that seemed to be causing me issues.</p>
<p>- Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.blog.pythonlibrary.org/2010/02/03/another-step-by-step-sqlalchemy-tutorial-part-1-of-2/comment-page-1/#comment-22817</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 05 Feb 2010 19:21:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.blog.pythonlibrary.org/?p=487#comment-22817</guid>
		<description>@ jotr,

I changed the query in this post to use an equality check rather than using &quot;like&quot; since that seemed to be causing me issues.

- Mike</description>
		<content:encoded><![CDATA[<p>@ jotr,</p>
<p>I changed the query in this post to use an equality check rather than using &#8220;like&#8221; since that seemed to be causing me issues.</p>
<p>- Mike</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.682 seconds -->

