Re: [sqlalchemy] Parent of the parent (relationship) as a hybrid property

2011-12-06 Thread Daniel Nouri
On Mon, Dec 5, 2011 at 11:30 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 5, 2011, at 1:39 PM, Daniel Nouri wrote: Thanks for your explanation.  I haven't used hybrid a lot yet and this helped me understand what it does and what not. Your last example that uses a

[sqlalchemy] Will scoped_session release database resource after thread finished?

2011-12-06 Thread shinningstar
When using scoped_session, only one session is used in each thread. That means I do not need to call close() during the lifetime of thread. How about the connection of session occupied if thread finished without calling close()? -- You received this message because you are subscribed to the

Re: [sqlalchemy] Complex foreign key constraint

2011-12-06 Thread Michael Bayer
yes, I had an intuition that a composite FK could do it as I've seen that approach before, but I couldn't figure it out. we have test coverage for cases exactly like that as well and I think I may even add this to the docs. On Dec 6, 2011, at 12:17 AM, Jackson, Cameron wrote: Just to follow

Re: [sqlalchemy] Parent of the parent (relationship) as a hybrid property

2011-12-06 Thread Daniel Nouri
On Tue, Dec 6, 2011 at 12:38 PM, Daniel Nouri daniel.no...@gmail.com wrote: On Mon, Dec 5, 2011 at 11:30 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 5, 2011, at 1:39 PM, Daniel Nouri wrote: Thanks for your explanation.  I haven't used hybrid a lot yet and this helped me

Re: [sqlalchemy] Parent of the parent (relationship) as a hybrid property

2011-12-06 Thread Daniel Nouri
On Tue, Dec 6, 2011 at 3:33 PM, Daniel Nouri daniel.no...@gmail.com wrote: Here's a little generalization of that GrandparentTransformer that I came up with.  class ParentalTransformer(Comparator):    def __init__(self, expression, level):        super(ParentalTransformer,

RE: [sqlalchemy] Complex foreign key constraint

2011-12-06 Thread Jackson, Cameron
Hi Mike, In case you haven't been following the SO question, I've added another answer which is basically Erwin's solution done with SQLAlchemy. Feel free to use all or part of the code I've put up in any additions you make to the SQLA docs. I think people could really benefit from seeing the

[sqlalchemy] SQLAlchemy emitting INTEGER instead of SERIAL- postgres sequence isn't created

2011-12-06 Thread Jackson, Cameron
For the background to the code I'm using, see this Stack Overflow question: http://stackoverflow.com/questions/8394177/complex-foreign-key-constraint-in-sqlalchemy/8408659 My declarative code looks like this: from MyGlobals import Base from sqlalchemy import Column, Integer, String,

Re: [sqlalchemy] SQLAlchemy emitting INTEGER instead of SERIAL- postgres sequence isn't created

2011-12-06 Thread Michael Bayer
On Dec 6, 2011, at 8:02 PM, Jackson, Cameron wrote: For the background to the code I'm using, see this Stack Overflow question: http://stackoverflow.com/questions/8394177/complex-foreign-key-constraint-in-sqlalchemy/8408659 My declarative code looks like this: from MyGlobals

RE: [sqlalchemy] SQLAlchemy emitting INTEGER instead of SERIAL- postgres sequence isn't created

2011-12-06 Thread Jackson, Cameron
Thought it might be something like that. For now I guess I'll just make the change manually. Thanks. Cameron Jackson Engineering Intern Air Operations Thales Australia Thales Australia Centre, WTC Northbank Wharf, Concourse Level, Siddeley Street, Melbourne, VIC 3005, Australia Tel: +61 3 8630

Re: [sqlalchemy] SQLAlchemy emitting INTEGER instead of SERIAL- postgres sequence isn't created

2011-12-06 Thread Michael Bayer
Use the latest tip: http://hg.sqlalchemy.org/sqlalchemy/archive/default.tar.gz and here's an example: from sqlalchemy import Integer, ForeignKey, String, \ Column, UniqueConstraint, ForeignKeyConstraint from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import

RE: [sqlalchemy] SQLAlchemy emitting INTEGER instead of SERIAL- postgres sequence isn't created

2011-12-06 Thread Jackson, Cameron
Hah! When you said I'd have to wait for a patch, I didn't expect to get one same-day! Thanks so much for your help with this Mike. After all this, I'll definitely be donating to SQLAlchemy when I get paid next Thursday :) Cameron Jackson Engineering Intern Air Operations Thales Australia

[sqlalchemy] Single Table Inheritance, multiple mappers and default (base) mapper

2011-12-06 Thread kris
I am using a single table scheme to store for a set of resource types. I would like to load a specific class if a mapper is defined and use the base class if no more specific version can be found. Is there a way to do this? i.e. resource = Table('resource',