[sqlalchemy] How can I set table constraints with DeferredReflection?

2014-04-02 Thread Rob Crowell
I'm using the ORM and one of my tables does not have a primary key defined. I am also using DeferredReflection, and I can't seem to figure out how to defer the PrimaryKeyConstraint until Base.prepare() runs. Any pointers? Base = declarative_base(cls=DeferredReflection) class

Re: [sqlalchemy] Trouble filtering binary columns with tuple_ and an in_ clause against Postgres

2014-02-28 Thread Rob Crowell
and 0.9. On Feb 27, 2014, at 7:29 PM, Michael Bayer mik...@zzzcomputing.comjavascript: wrote: On Feb 27, 2014, at 4:38 PM, Rob Crowell rob.c...@moat.com javascript: wrote: # in_ clause with 1 STRING, 1 BINARY filter_cols = tuple_(HashTest.hash_val, HashTest.hash_type

[sqlalchemy] Trouble filtering binary columns with tuple_ and an in_ clause against Postgres

2014-02-27 Thread Rob Crowell
When I pass binary data to a multi-column in_ clause, I seem to be geting inconsistent results and I need some help! I did some testing with MySQL, Postgres, and Vertica (connecting via https://pypi.python.org/pypi/vertica-sqlalchemy/0.1). It appears MySQL works correctly but both Postgres

[sqlalchemy] Help with DeferredReflection and setting up an engine at runtime?

2014-02-17 Thread Rob Crowell
I am having a bit of trouble getting DeferredReflection working the way I want; not sure if I am overlooking something obvious or if I just don't really understand how it's supposed to work. I'm trying to define my models before creating my engine (this does not work): Base =

Re: [sqlalchemy] Help with DeferredReflection and setting up an engine at runtime?

2014-02-17 Thread Rob Crowell
Interesting, thanks Michael. I didn't realize autoload was implied when using DeferredReflection but that makes sense. Thanks! On Monday, February 17, 2014 7:17:34 PM UTC-5, Michael Bayer wrote: On Feb 17, 2014, at 6:23 PM, Rob Crowell robcc...@gmail.com javascript: wrote: I am having

Re: [sqlalchemy] Better approach to filtering a relationship collection than using contains_eager()?

2013-02-27 Thread Rob Crowell
or contains_eager or any of that yet. On Feb 27, 2013, at 2:07 AM, Rob Crowell robcc...@gmail.com javascript: wrote: Example code: https://gist.github.com/rcrowell/5045832 I have Person and Town tables, which are joined in a many-to-many fashion through a VisitedDestinations table. I

Re: [sqlalchemy] Better approach to filtering a relationship collection than using contains_eager()?

2013-02-27 Thread Rob Crowell
, VisitedDestinations.town).\ options(contains_eager(Person.visited_destinations, VisitedDestinations.town)).\ filter(Town.name.in_(['Atlanta', 'Memphis'])) On Feb 27, 2013, at 1:48 PM, Rob Crowell rob.c...@moat.com javascript: wrote: Sure! Here's the query I am attempting to replicate: SELECT

Re: [sqlalchemy] Better approach to filtering a relationship collection than using contains_eager()?

2013-02-27 Thread Rob Crowell
, at 2:40 PM, Rob Crowell rob.c...@moat.com javascript: wrote: Ah okay, so you do recommend the contains_eager approach. I guess this is exactly the use-case it is designed for? I always get a little scared when I try using advanced features of SQLAlchemy :) One last question. The query here

[sqlalchemy] Difference between ZopeTransactionExtension(keep_session=True) and sessionmaker(expire_on_commit=False)?

2013-02-19 Thread rob . crowell
I'm building a pyramid application using pyramid_tm and ZopeTransactionExtension. We've written a little subscriber on NewResponse that writes out some values to a log file about the current user (request.user.id) after each request. For anybody that knows pyramid pretty well, we set the

Re: [sqlalchemy] Complicated filter clause causes recursion depth exceeded exception

2013-01-22 Thread rob . crowell
Thanks Michael, Writing a big list of conditions and combining them with and_(*conditions) worked well. I was indeed querying like this before: for condition in conditions: q = q.filter(condition) print q On Friday, January 18, 2013 6:00:04 PM UTC-5, Michael Bayer wrote: On Jan 18,

[sqlalchemy] Complicated filter clause causes recursion depth exceeded exception

2013-01-18 Thread rob . crowell
I haven't boiled this down to a short test case yet, but when my WHERE clause gets especially long I start getting the recursion depth exceeded exception. Is this a well-known limitation of sqlalchemy? We're running this query in production currently without SQLAlchemy, and it performs fine,

[sqlalchemy] Re: Is it possible to define multiple model objects that refer to the same table?

2012-11-21 Thread Rob Crowell
...@zzzcomputing.com wrote: On Nov 16, 2012, at 2:59 PM, Rob Crowell wrote: Thanks for the help so far Michael!  I can explain a little more about what I'm trying to do (I'm using a fictional application here but I think it pretty accurately translates into my actual application). BACKGROUND

[sqlalchemy] Re: Is it possible to define multiple model objects that refer to the same table?

2012-11-16 Thread Rob Crowell
On Nov 15, 10:48 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Nov 15, 2012, at 7:33 PM, Rob Crowell wrote: Sorry, that got cut off at the end. class IssueTag(Base):     __tablename__ = 'issue_user_tag' sqlalchemy.exc.InvalidRequestError: Table 'issue_user_tag