Jorge Vargas wrote:
> Hi,
> 
> I'm working on a project where I got several "read only tables" that
> are dependent on a third-party, I got several vainlla SQL queries to
> get the data I need of them and I was wondering which will be the best
> way to load them up into SA. The queries themselfs are quite complex
> with several inner joins and other nasty SQL, the queries don't change
> except for 1 paramenter I need to pass in which is the "root item" i'm
> looking for.
> 
> I was wondering if there was a way
> - I could create a class with no Table object that will be populated
> from the resulting query,
> - or if I should go with a db view and/or stored procedure, (how will
> I call that form sa?)
> - or if I should translate the raw query into SA's sqlexpresions
> - or should I just bypass SA and do a raw dbapi call?
> 
> which will be the best way to handle this situation? Keep in mind this
> data is read-only so the only function I need is getInfo(itemId),
> which will execute the query and return Table-like object.

If you've already got the complex SQL and it's working for you, might as 
well use it:

   query = text('SELECT foo, bar FROM baz WHERE root_item = :root')
   resultset = connection.execute(query, root=123)

The only modification of the original query needed is changing the 
variable portion to a named bind parameter with the :colon syntax.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to