[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 Person(Ba

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

2014-02-28 Thread Rob Crowell
or 0.8 and 0.9. > > On Feb 27, 2014, at 7:29 PM, Michael Bayer > > > wrote: > > > On Feb 27, 2014, at 4:38 PM, Rob Crowell > > 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 an

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 > > wrote: > > I am havin

[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 = declarative_bas

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

2013-02-27 Thread Rob Crowell
, February 27, 2013 2:48:21 PM UTC-5, Michael Bayer wrote: > > > On Feb 27, 2013, at 2:40 PM, Rob Crowell > > 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

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

2013-02-27 Thread Rob Crowell
hought you > had a more complex query.contains_eager() doesn't impact what's > queried, only how results are used with the resulting objects, and is > usually used with join(), just like this: > > session.query(Person).\ > join(Person.visited_destinations, Vis

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

2013-02-27 Thread Rob Crowell
of that SQL to route into > your contains_eager(). We do that second. > > So let me know if you know the actual SQL you want to do first; we'd work > from there. Don't deal with joinedload or contains_eager or any of that > yet. > > > On Feb 27, 2013, at 2:07 AM,

Re: [sqlalchemy] is there a more proper way to chain dynamic "or" clauses ?

2013-02-26 Thread Rob Crowell
I'm not sure of the proper way to link to previous discussions (or indeed if I am even the hapless user that Michael was referring to!), but this sounds like what Michael was talking about for reference: https://groups.google.com/d/topic/sqlalchemy/ETFlrQrmdHk/discussion On Saturday, February

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

2013-02-26 Thread Rob Crowell
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 want to write a query which will return People that have visited either Atlanta or Memphis. I have a working example using co

[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 requ

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, 2

[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
olumns(IssueTypeLabel) This code correctly prints the following: issue type: ['id', 'type', 'created', 'num_visits'] issue label: ['id', 'label_id', 'created', 'num_visits'] issue type label: ['id',

[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 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] Re: Is it possible to define multiple model objects that refer to the same table?

2012-11-15 Thread Rob Crowell
ns on an existing Table object. On Thursday, November 15, 2012 7:32:29 PM UTC-5, Rob Crowell wrote: > > I'm working with a denormalized cache schema, and I've run into a > situation where it would be helpful to be able to create multiple classes > that extend Base but refer t

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

2012-11-15 Thread Rob Crowell
I'm working with a denormalized cache schema, and I've run into a situation where it would be helpful to be able to create multiple classes that extend Base but refer to the same __tablename__. Is this possible to do? I am getting this Exception: sqlalchemy.exc.InvalidRequestError: Table '