[sqlalchemy] Metadata - Inherited Tables, Columns

2009-04-13 Thread Jarrod Chesney
Hi, Is there a way of telling if a table is inherited from another table and which tables it inherits from in the Metadata? Further to this, Is there a way of telling which column definitions come from which table? --~--~-~--~~~---~--~~ You received this

[sqlalchemy] Re: Metadata - Inherited Tables, Columns

2009-04-13 Thread az
Is there a way of telling if a table is inherited from another table and which tables it inherits from in the Metadata? inheritance is not really sql notion... so a) look at the mapper.inherits (towards root) and/or mapper.polymorphic_itereator() (towards leafs) b) see if table's primary

[sqlalchemy] Re: Should we separate business logic and ORM mapping classes.

2009-04-13 Thread Nebur
A good question. I think we agree that both ways can work well... Usually, I do prefer the less OO style. In your example, a pure mapping class and business logic in a user manager. The main reason is that what you call OO style seems to enforce a lot of arbitrary decisions. For example, when

[sqlalchemy] Re: Should we separate business logic and ORM mapping classes.

2009-04-13 Thread az
i would bundle them into one... but would probably split on another level. adding items to a user may well be posessions... so it depends. That might well be a model of User with related stuff, which is mapped to database in another way (one2many or Relator object/m2m or whatever), and is

[sqlalchemy] Numeric() type behavior

2009-04-13 Thread Thomas
Hi, I am a new sqlalchemy user. I'm a bit confused by the behavior of the Numeric data type. Consider the following code: from sqlalchemy import * db = create_engine('sqlite:///test.db') metadata = MetaData() table = Table('thetable',metadata,Column('x',Numeric(scale=3)),Column ('y',Float))

[sqlalchemy] Re: Numeric() type behavior

2009-04-13 Thread Michael Bayer
Its possible that SQLite doesn't respect the scale argument. I'd look at the full SQL generated to ensure its what you'd expect, then check sqlite's documentation on this. Thomas wrote: Hi, I am a new sqlalchemy user. I'm a bit confused by the behavior of the Numeric data type. Consider

[sqlalchemy] Re: Numeric() type behavior

2009-04-13 Thread Mike Conley
SQLite has no concept of fixed decimal types. Take a look at http://www.sqlite.org/datatype3.html for what is supported. It might be possible to make an effective TypeDecorator using the decimal module introduced in Python 2.4. In fact that would probably make a good recipe for the SQLAlchemy

[sqlalchemy] help with a tricky property mapping

2009-04-13 Thread Dusty Phillips
Hi there, I've got a crappy legacy database that has a _rowid and an id column (they have totally separate meanings. In my orm, I want 'id' to map to _rowid and 'document_id' to map to id in the table. Easy enough -- I set it up like this: mapper(Document, documents, properties={

[sqlalchemy] Re: Metadata - Inherited Tables, Columns - PostGreSQL

2009-04-13 Thread Jarrod Chesney
Thanks, I'll look at that but it doesn't sound very concrete. IE using a foreign key to see if somethings inherited. Question 1 From the sqlalchemy mapper configuration, PostGreSQLs version of inheritence sounds like the concrete variary, as it automatically joins the tables together with a

[sqlalchemy] Re: Metadata - Inherited Tables, Columns

2009-04-13 Thread Jarrod Chesney
I'll look into a) do the mappers pick up foreign key constraints and the polymorphic/inherited details from the metadata when their created or do you have to specify them? - As a last resort i can query the data dictionary. Question 1 From the sqlalchemy mapper configuration, PostGreSQLs version

[sqlalchemy] Re: Metadata - Inherited Tables, Columns

2009-04-13 Thread az
On Tuesday 14 April 2009 00:13:10 Jarrod Chesney wrote: I'll look into a) do the mappers pick up foreign key constraints and the polymorphic/inherited details from the metadata when their created or do you have to specify them? both, if ambigious u have to specify manualy. dunno about the

[sqlalchemy] Re: help with a tricky property mapping

2009-04-13 Thread az
mapper(Document, documents, properties={ 'document_id': documents.c.id, # document_id ORM property In the past, I have successfully mapped these properties using synonym, but this time I'm confused because I'm not sure how to define the synonym to a different column name. How do I