Re: [sqlalchemy] create_all() fails silently

2010-08-05 Thread Michael Hipp
On 8/4/2010 10:03 PM, Mike Conley wrote: On Wed, Aug 4, 2010 at 9:39 PM, Michael Hipp mich...@hipp.com mailto:mich...@hipp.com wrote: Can someone tell me why this code won't create any tables? The tables are defined in another file that calls declarative_base(). I presume the

Re: [sqlalchemy] create_all() fails silently

2010-08-05 Thread Mike Conley
On Thu, Aug 5, 2010 at 6:29 AM, Michael Hipp mich...@hipp.com wrote: On 8/4/2010 10:03 PM, Mike Conley wrote: Thanks. But by the time I'm done there will be at least a dozen of those otherfiles. Which one do I get Base from? You can put the declaration of Base in a common file that is

Re: [sqlalchemy] create_all() fails silently

2010-08-05 Thread Michael Hipp
On 8/5/2010 8:26 AM, Mike Conley wrote: On Thu, Aug 5, 2010 at 6:29 AM, Michael Hipp mich...@hipp.com mailto:mich...@hipp.com wrote: On 8/4/2010 10:03 PM, Mike Conley wrote: Thanks. But by the time I'm done there will be at least a dozen of those otherfiles. Which one do I get

[sqlalchemy] Can an object span sessions?

2010-08-05 Thread Michael Hipp
Can this be made to work? session = Session() rec = MyModel() # create a record session.close() # Sometime later session = Session() rec.name = Fred # modify the record session.commit() # try to save modified record session.close() Does the session have to be global to this

Re: [sqlalchemy] Can an object span sessions?

2010-08-05 Thread Michael Bayer
On Aug 5, 2010, at 11:54 AM, Michael Hipp wrote: Can this be made to work? session = Session() rec = MyModel() # create a record session.close() # Sometime later session = Session() rec.name = Fred # modify the record session.commit() # try to save modified record

Re: [sqlalchemy] Can an object span sessions?

2010-08-05 Thread Michael Hipp
On 8/5/2010 11:03 AM, Michael Bayer wrote: On Aug 5, 2010, at 11:54 AM, Michael Hipp wrote: Can this be made to work? session = Session() rec = MyModel() # create a record session.close() # Sometime later session = Session() rec.name = Fred # modify the record

[sqlalchemy] Re: inheritance and column_property() - subqueries are being limited

2010-08-05 Thread SQLAlchemy User
...and we're back to the same issue with another column_property: that is, How do you create column_properties with subqueries on child objects where the subquery references another child object? This: PC_avgdist_subq = select([func.avg(func.distance(PC.pt.RAW,

[sqlalchemy] now with code goodness: problems with single-table inheritance and column_properties?

2010-08-05 Thread Zippy P
I have the following code: from objects import * class Device(Base): __tablename__=testdev devtype = Column(Unicode(20), primary_key = True) __mapper_args__ = {'polymorphic_on': devtype} mac = Column(Unicode(128), primary_key = True) switch_mac = Column(Unicode(128), ForeignKey(mac)) switch =

[sqlalchemy] Re: now with code goodness: problems with single-table inheritance and column_properties?

2010-08-05 Thread SQLAlchemy User
Trying again without tab indents. Hopefully the formatting works this time. from objects import * class Device(Base): __tablename__=testdev devtype = Column(Unicode(20), primary_key = True) __mapper_args__ = {'polymorphic_on': devtype} mac = Column(Unicode(128), primary_key =

Re: [sqlalchemy] now with code goodness: problems with single-table inheritance and column_properties?

2010-08-05 Thread Michael Bayer
On Aug 5, 2010, at 5:06 PM, Zippy P wrote: I have the following code: from objects import * class Device(Base): __tablename__=testdev devtype = Column(Unicode(20), primary_key = True) __mapper_args__ = {'polymorphic_on': devtype} mac = Column(Unicode(128),

[sqlalchemy] Re: now with code goodness: problems with single-table inheritance and column_properties?

2010-08-05 Thread SQLAlchemy User
On Aug 5, 3:11 pm, Michael Bayer mike...@zzzcomputing.com wrote: Ultimately you're looking for a self-referential correlation here.   In SQL, that always implies using aliases.   Your column_property needs to be against aliased(PC) and not PC itself.     Thanks - that did the trick. I

[sqlalchemy] Single table polymorphic scheme with different column types

2010-08-05 Thread anthony
Hi, First message here in the sqlalchemy mailing list. I was working with a previous version of sqlalchemy (0.6beta1) and while updating sqlalchemy, ran into a problem with polymorphic classes. Basically we're using a single table inheritance scheme and we want the value column to have different