Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-06 Thread Michael Bayer
On Feb 6, 2014, at 1:56 PM, Adrian Robert wrote: > Well, using the mapper event would be nicer, but in any case I was already > iterating over Base.classes and adding them to my own module's namespace like > so: > >globals()[cls.__name__] = cls > > It works for the rest of my application

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-06 Thread Adrian Robert
Well, using the mapper event would be nicer, but in any case I was already iterating over Base.classes and adding them to my own module's namespace like so: globals()[cls.__name__] = cls It works for the rest of my application being able to see the classes by importing the module, but appa

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-06 Thread Michael Bayer
Python pickle can’t pickle class instances where the class isn't locatable as module-level imports. As automap necessarily creates classes on the fly, these classes aren’t part of any module. to have them part of a module you’d want to use an event to place them in the namespace of one of your

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-06 Thread Adrian Robert
One other point, I was trying out the dogpile cache example and ran into (after I stuck a ".encode('utf-8')" into the key mangler since I'm using Python-3 and pylibmc): _pickle.PicklingError: Can't pickle : attribute lookup sqlalchemy.ext.automap.Person failed This was fixed by a hack sql

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-02 Thread Adrian Robert
Thanks, that works beautifully. I had noticed name_for_scalar_relationship parameter but I guess wasn't confident enough that I understood what was going on to try it. :-[ -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-01 Thread Michael Bayer
On Feb 1, 2014, at 11:50 AM, Adrian Robert wrote: > Hi, > > I'm new to sqlalchemy though I've used other ORMs (e.g. Hibernate) before, > and I'm trying to use the new automap feature. > > However it seems to be using the foreign table name rather than a suffixed > version of the column name

[sqlalchemy] Automap and naming of relationship attributes

2014-02-01 Thread Adrian Robert
Hi, I'm new to sqlalchemy though I've used other ORMs (e.g. Hibernate) before, and I'm trying to use the new automap feature. However it seems to be using the foreign table name rather than a suffixed version of the column name when naming relationships. Is there a reason for doing it this wa