Re: [sqlalchemy] Simple one-to-one translation with hybrid_attribute

2011-08-01 Thread Ross Vandegrift
On Mon, 2011-08-01 at 17:22 -0400, Michael Bayer wrote: > You're looking to convert from int->string using a mapping in a SQL > expression, so I think you'd need to write @state.expression as a CASE > statement. > > from sqlalchemy import case > >@state.expression >def state(self): >

[sqlalchemy] Simple one-to-one translation with hybrid_attribute

2011-08-01 Thread Ross Vandegrift
Hello everyone, Trying to use hybrid_attribute to provide friendly names for integers representing object states. Storage and retrieval works fine, but I can't get filtering working. I want the translation to happen on the Python side prior to filling in the query parameters, but hybrid_attribut

Re: [sqlalchemy] Re: Self-referential, one-to-one, reflexive mappings

2010-08-18 Thread Ross Vandegrift
s the OTHER entry in n1.node. Hence why I added the property an synonym. Ross > > > On Aug 18, 4:59 am, Ross Vandegrift wrote: > > Hi everyone, > > > > Does anyone have a good setup for one-to-one relationships that are > > always symmetric and provide

[sqlalchemy] Self-referential, one-to-one, reflexive mappings

2010-08-17 Thread Ross Vandegrift
person_m = orm.mapper(Person, person_t) marriage_m = orm.mapper(Marriage, marriage_t, properties={'partners': orm.relation(Person, backref="marriage")}) Ross -- Ross Vandegrift r...@kallisti.us "If the fight gets hot, the songs get hotter. If the going gets tough, the songs get tougher." --Woody Guthrie signature.asc Description: Digital signature

[sqlalchemy] polymorphic_on a join leads to incorrect collection

2010-08-11 Thread Ross Vandegrift
rPort() rp2.device = r2 rp2.binding = b2 s1 = CiscoSwitch() sp1 = CiscoSwitchPort() sp1.device = s1 sp1.binding = b1 s2 = JuniperSwitch() sp2 = JuniperSwitchPort() sp2.device = s2 sp2.binding = b2 session.add_all([r1, rp1, r2, rp2, s1, sp1, s2, sp2, b1, b2]) session.flush() session.commit() en

[sqlalchemy] ALLCAPS datatypes

2010-06-22 Thread Ross Vandegrift
? I guess I wonder this - which am I "supposed" to use? Ross -- Ross Vandegrift r...@kallisti.us "If the fight gets hot, the songs get hotter. If the going gets tough, the songs get tougher." --Woody Guthrie signature.asc Description: Digital signature

Re: [sqlalchemy] Mixed inheritance mapping and multiple binds

2010-01-19 Thread Ross Vandegrift
nately, I have no need for that functionality. > On Jan 18, 2010, at 6:27 PM, Ross Vandegrift wrote: > > engine = create_engine('sqlite:///:memory:', echo=True) > > metadata.create_all(engine) > > binds = { device_table : engine, > > switch_table : engi

[sqlalchemy] Mixed inheritance mapping and multiple binds

2010-01-18 Thread Ross Vandegrift
session = Session() r1 = CiscoRouter() r2 = JuniperRouter() parent1 = CiscoSwitch() parent2 = CiscoSwitch() child1 = JuniperSwitch() child1.upstream1 = parent1 child1.upstream2 = parent2 child2 = JuniperSwitch() child2.upstream1 = parent1 child2.upstream2 = parent2 session.add_all([r1, r2]) sess

[sqlalchemy] Re: VIEW alternative in SQLAlchemy

2009-08-09 Thread Ross Vandegrift
ary Selectable object. Selectable is the base class for things like select() in SA. This feature is awesome! Rather than specifying your Table object to orm.mapper, specify a Selectable that returns rows that are what you want to see. -- Ross Vandegrift r...@kallisti.us "If the fight gets

[sqlalchemy] Re: ORM lifecycle questions

2008-12-17 Thread Ross Vandegrift
On Thu, Dec 11, 2008 at 02:59:39PM -0500, Michael Bayer wrote: > On Dec 11, 2008, at 2:04 PM, Ross Vandegrift wrote: > > So if I do something like this: > > > > p = meta.session.query(model.Pool) > > pool = p.get(7) > > meta.session.refresh(pool) > > Invali

[sqlalchemy] ORM lifecycle questions

2008-12-11 Thread Ross Vandegrift
pool) InvalidRequestError: Instance 'p...@0xa6aca8c' is already persistent Now I'm really confused. What did I do? -- Ross Vandegrift r...@kallisti.us "If the fight gets hot, the songs get hotter. If the going gets tough, th

[sqlalchemy] [PATCH] add MSMediumInteger

2008-08-20 Thread Ross Vandegrift
+def get_col_spec(self): +if self.length is not None: +return self._extend("MEDIUMINT(%(length)s)" % {'length': self.length}) +else: +return self._extend("MEDIUMINT") + + class MSTinyInteger(MSInteger): """

[sqlalchemy] Re: sqlalchemy 0.4 and multiple database binds

2008-08-18 Thread Ross Vandegrift
On Mon, Aug 18, 2008 at 10:14:44AM -0400, Michael Bayer wrote: > On Aug 18, 2008, at 10:07 AM, Ross Vandegrift wrote: > > > > > Hello everyone, > > > > According to the Pylons wiki docs on multiple engines with SQLALchemy > > 0.4, I should be able to do: &

[sqlalchemy] sqlalchemy 0.4 and multiple database binds

2008-08-18 Thread Ross Vandegrift
y "bind" - which leads me to believe that the documentation gives the incorrect approach. -- Ross Vandegrift [EMAIL PROTECTED] "The good Christian should beware of mathematicians, and all those who make empty prophecies. The danger already exists that the mathematicians have made a covena

[sqlalchemy] Re: MySQL Server Side Cursors

2008-04-25 Thread Ross Vandegrift
I haven't converted any apps to it from my old paging code, but if I was starting now, I would use it. -- Ross Vandegrift [EMAIL PROTECTED] "The good Christian should beware of mathematicians, and all those who make empty prophecies. The danger already exists that the mathematicians have

[sqlalchemy] Re: web application too slow

2008-04-07 Thread Ross Vandegrift
ou have transparent backgrounds? There's a pretty major performance problem with Mozilla and X11 where render operations on pages with transparent divs are excruciatingly slow on many video cards. The problem is compounded by multiple layers of transparency. In other words - make sure the slo

[sqlalchemy] SQLError: (OperationalError) (2013, 'Lost connection to MySQL server during query')

2008-02-25 Thread Ross Vandegrift
cle = 600 Neither seems to help though. Anyone have any ideas? Perhaps I'm doing something wrong in configuring production.ini? Ross -- Ross Vandegrift [EMAIL PROTECTED] "The good Christian should beware of mathematicians, and all those who make empty prophecies. The danger already ex