[sqlalchemy] self-referential many-to-many relationships and mixins

2013-08-13 Thread till.plewe
I am using python 3.3 and sqlalchemy 0.8.2 I am trying to define a self-referential many-to-many relationship for a class where the primary key is provided by a mixin. Defining the primary directly in the class works. Using the mixin does not. I would be grateful for any suggestions or

Re: [sqlalchemy] self-referential many-to-many relationships and mixins

2013-08-13 Thread Simon King
On Tue, Aug 13, 2013 at 2:07 PM, till.plewe till.pl...@gmail.com wrote: I am using python 3.3 and sqlalchemy 0.8.2 I am trying to define a self-referential many-to-many relationship for a class where the primary key is provided by a mixin. Defining the primary directly in the class works.

Re: [sqlalchemy] self-referential many-to-many relationships and mixins

2013-08-13 Thread till plewe
Thank you. That does the trick. Till On Tue, Aug 13, 2013 at 10:54 PM, Simon King si...@simonking.org.uk wrote: On Tue, Aug 13, 2013 at 2:07 PM, till.plewe till.pl...@gmail.com wrote: I am using python 3.3 and sqlalchemy 0.8.2 I am trying to define a self-referential many-to-many

[sqlalchemy]

2013-08-13 Thread Paul Balomiri
Hi, I am trying to build an attribute_mapped_collection reference from table people (Mapped class is called Person). However, I would like to get a list of entities for each key. I have the following tables with the relevant PK and FK listed Person: - id PersonToAddress: - id - person_id -

[sqlalchemy] attribute_mapped_collection use as a key-list dictionary

2013-08-13 Thread Paul Balomiri
sorry for having forgot to add a subject 2013/8/13 Paul Balomiri paulbalom...@gmail.com: Hi, I am trying to build an attribute_mapped_collection reference from table people (Mapped class is called Person). However, I would like to get a list of entities for each key. I have the following

Re: [sqlalchemy] attribute_mapped_collection use as a key-list dictionary

2013-08-13 Thread Michael Bayer
On Aug 13, 2013, at 11:44 AM, Paul Balomiri paulbalom...@gmail.com wrote: I would like to get a list as value for the dict, such that i can assign more than one entity to any one key. The output should look like this: {u'home': [Address object at 0x29568d0,Address object at ...] , u'work':

Re: [sqlalchemy] Mapping views as Table/ORM

2013-08-13 Thread temp4746
Seems like a reasonable way to do this until maybe one day proper support is added to sqlalchemy. I'm still missing one thing though, it seems like there is a feature that allows you to reflect views, but it reflects them as a Table and as such when you later on try to create_all(), it will

Re: [sqlalchemy] Mapping views as Table/ORM

2013-08-13 Thread Michael Bayer
maybe use a separate MetaData collection when reflecting your views, so that create_all() isn't impacted. The View recipe could also be enhanced to support reflection, you can use the inspector to get at lists of columns individually:

Re: [sqlalchemy] Code organization with declarative models

2013-08-13 Thread George Sakkis
On Tuesday, August 13, 2013 12:59:57 AM UTC+3, Ams Fwd wrote: On 08/12/2013 02:50 PM, George Sakkis wrote: Hello everyone, this is more of a code architecture and design question but I'm wondering what the best practices are regarding declarative models. On the one extreme, models

[sqlalchemy] Join textual query to SA query?

2013-08-13 Thread Amir Elaguizy
Hey guys, Questions about the following code in which I'm trying to take a textqual query and join it to a query builder query. 1) What is the correct way to do the in for the list of ids in the first query? My current way doesn't work and I'm not able to find a real good example 2) How can I

Re: [sqlalchemy] Cross-schema foreign keys reflection

2013-08-13 Thread Michael Bayer
cross-schema reflection is supported on PG but has caveats, see http://docs.sqlalchemy.org/en/rel_0_8/dialects/postgresql.html#remote-cross-schema-table-introspection for a discussion of recommended usage patterns. On Aug 13, 2013, at 5:11 PM, Jason ja...@deadtreepages.com wrote: Hello, I

Re: [sqlalchemy] Join textual query to SA query?

2013-08-13 Thread Michael Bayer
On Aug 10, 2013, at 4:41 PM, Amir Elaguizy aelag...@gmail.com wrote: Hey guys, Questions about the following code in which I'm trying to take a textqual query and join it to a query builder query. 1) What is the correct way to do the in for the list of ids in the first query? My

[sqlalchemy] CTE name quoting bug in 0.8

2013-08-13 Thread jtruscott
Hi, I updated sqlalchemy from 0.7.8 to 0.8.2 and one of my queries started failing. I had a CTE expression with capital letters in it's name, and in 0.8 it wasn't getting consistently quoted, but it worked in 0.7. I narrowed it down, and it only seems to happen in a query containing multiple

Re: [sqlalchemy] Updating a one-to-many relationship

2013-08-13 Thread csdrane
I'm afraid there are still some bugs in here that hopefully you can help with. class Creator(Base): __tablename__ = creators id = Column(Integer, primary_key = True) company_id = Column(Integer, ForeignKey('companies.id')) creator = Column(String(100), nullable=False,

[sqlalchemy] DeferredReflection and mapper

2013-08-13 Thread Lukasz Szybalski
Hello, How do I go from class like defeinition to below with mapper. The docs in 0.8 say I can use: from sqlalchemy.ext.declarative import DeferredReflectionBase = declarative_base() class MyClass(DeferredReflection, Base): __tablename__ = 'mytable' but how do I do below with