<div dir="ltr">Thanks for the response Cameron. No amount of 'googling' could provide me with that caliber response :-)<div><br></div><div>So, it seems regardless I would need a database. </div><div><br><div><br></div>
<div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Feb 2, 2014 at 1:58 AM, Cameron Simpson <span dir="ltr"><<a href="mailto:cs@zip.com.au" target="_blank">cs@zip.com.au</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 01Feb2014 20:46, Rita <<a href="mailto:rmorgan466@gmail.com">rmorgan466@gmail.com</a>> wrote:<br>

> I want to learn more about ORMs so I stumbled upon, SqlAlchemy.<br>
><br>
> If i had a JSON document (or XML, CSV, etc.._) is it possible to convert it<br>
> to a SQLAlchemy objects? I like the ability to query/filter (<br>
> <a href="http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html#common-filter-operators" target="_blank">http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html#common-filter-operators</a>)<br>
>  the<br>
> data assuming I set up the proper schema.<br>
<br>
</div>Well, not as directly as you might hope. As I recall, SQLAlchemy<br>
ORMs provide an easy way to make objects representing database<br>
entities and whose methods automatically drive the necessary SQL<br>
actions to manipulate them.<br>
<br>
On that basis, you won't get anywhere without loading up the<br>
JSON/XML/etc, parsing it for relevant information (trivial with<br>
CSV, less so for structured data like JSON or XML), and storing it<br>
in a database. To which you then point SQLAlchemy.<br>
<br>
So you're already doing the fiddly bit just to get stuff into the database.<br>
<br>
The neat filter operations you cite are actually done by special<br>
methods on the objects representing tables and columns. For example,<br>
<br>
  User.name == None<br>
<br>
is done via the __eq__ method of "User.name". And they return<br>
strings: bare SQL. The beauty of this is that one can write almost<br>
idiomatic python, and SQLA will generate correct SQL in the right<br>
dialect for the database backend, and with all the values correctly<br>
escaped.<br>
<br>
However, it does presume you _already_ have a backend that can be<br>
queried with SQL.<br>
<div class="im"><br>
> Also, is this a valid way to use an ORM suite?<br>
<br>
</div>Well, in principle sure. But SQLA won't do it for you directly. It really<br>
is for data already stored in an SQL queriable database.<br>
<br>
Your point about using SQLA's filter operations is right, _provided_<br>
you have already loaded the original data into a database with the<br>
right schema. If you've done that work, then SQLA may well serve<br>
you well from that point on.<br>
<br>
Cheers,<br>
<span class="HOEnZb"><font color="#888888">--<br>
Cameron Simpson <<a href="mailto:cs@zip.com.au">cs@zip.com.au</a>><br>
<br>
We knew Army cadets were involved because they cut through two fences<br>
to get to the goats, and 15 feet away there was an unlocked gate.<br>
        - a director of sports information in the Navy, regarding the theft<br>
          of some mascots from the Naval Academy by Army rivals<br>
--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>--- <span>Get your facts first, then you can distort them as you please.</span>--
</div>