On Jun 10, 2013, at 12:46 PM, Charlie Clark <charlie.cl...@clark-consulting.eu> 
wrote:

> Hi Mike,
> 
> Am 10.06.2013, 18:38 Uhr, schrieb Michael Bayer <mike...@zzzcomputing.com>:
> 
>> I'm not sure here where the pain point is for you, just how to get access to 
>> something.execute()?   Session has execute(), Engines and Connections can be 
>> stuck onto Sessions, there's any combination you'd want there.  Anything 
>> with an execute() on it, you can send an insert()/update() etc. into.
> 
> I've already managed to get connections and execute. Let me provide some 
> context:
> 
> I have some models defined for a Pyramid application:
> 
> https://bitbucket.org/charlie_x/python-httparchive/src/43bd077a2d75626fe4da5251695526d7bdd7274f/httparchive/httparchive/models.py?at=default
> 
> And some necessary but ugly housekeeping scripts:
> 
> https://bitbucket.org/charlie_x/python-httparchive/src/43bd077a2d75626fe4da5251695526d7bdd7274f/httparchive/httparchive/scripts/update.py?at=default
> 
> Currently, I get the connection and just execute the statements. But, of 
> course, some of won't work with both MySQL and Postgres.
> 
> I have currently naively tried
> 
> from httparchive.models import Page
> pages = Page()
> pages.update(…)
> 
> This fails because
> "AttributeError: 'Page' object has no attribute 'update'"
> 
> How should I be doing this instead?

Page.__table__.update()

or agnostic of declarative:

from sqlalchemy import inspect

pages = inspect(Page).local_table

pages.update()

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to