Re: [sqlalchemy] Handling detached instances

2014-09-30 Thread Wichert Akkerman
On 30 Sep 2014, at 23:18, tonthon wrote: > I didn't knew merge was supposes to be used in such a case, it works like a > charm. > Following that tip, I've added this decorator : > > >>> def cache_wrapper(func): > >>> """ ensure a model returned from a cached function is a

Re: [sqlalchemy] Handling detached instances

2014-09-30 Thread tonthon
Le mardi 30 septembre 2014 13:28:16 UTC+2, Simon King a écrit : > > On Tue, Sep 30, 2014 at 8:52 AM, tonthon > > wrote: > > Hi, > > > > I'm using dogpile cache to store objects in a redis database, here's the > > sample function I use for my tests : > > > @region.cache_on_arguments()

[sqlalchemy] Re: Define a model as a subset of table data

2014-09-30 Thread Jonathan Vanasco
Two things that won't answer your question: 1. I've had better luck using Mixins instead of inherited subclasses. The main reason is maintenance -- when you end up looking at AddressHistory in 2 years, you might not remember that MostRecentAddress inherits from it. 2. Your sql doesn't make sen

Re: [sqlalchemy] Define a model as a subset of table data

2014-09-30 Thread Michael Bayer
On Sep 30, 2014, at 4:48 PM, katie louise wrote: > SQLAlchemy newbie here. > > I'm trying to define a model (subclassed by another model) that represents a > subset of table data of the parent model. Specifically, I want the subclass > to map the most recent row for a given ID. > > For examp

[sqlalchemy] Define a model as a subset of table data

2014-09-30 Thread katie louise
SQLAlchemy newbie here. I'm trying to define a model (subclassed by another model) that represents a subset of table data of the parent model. Specifically, I want the subclass to map the most recent row for a given ID. For example, suppose I have the following model: class AddressHistory(Ba

[sqlalchemy] Re: NVARCHAR doubt

2014-09-30 Thread Mariano Mara
I just noticed that the error code comes from oracle directly and it is not sqlalchemy related. Looks like the best way is not to use an unicodetext field (if I plan to use to to group results). Probably I failed to read such limitation in oracle's doc. Sorry for the inconvenience. 2014-09-30 17:

[sqlalchemy] Re: NVARCHAR doubt

2014-09-30 Thread Mariano Mara
Sorry, I meant NCLOB, not NVARCHAR. 2014-09-30 16:57 GMT-03:00 Mariano Mara : > Hi there. I have some code that works ok in PG and now I need to make it > work with Oracle, however I am hitting this error with NVARCHAR and I am > not sure how to handle it. > > First a small code in order you can

[sqlalchemy] NVARCHAR doubt

2014-09-30 Thread Mariano Mara
Hi there. I have some code that works ok in PG and now I need to make it work with Oracle, however I am hitting this error with NVARCHAR and I am not sure how to handle it. First a small code in order you can reproduce it (as you can see "name" has been defined as UnicodeText): from sqlalchemy im

Re: [sqlalchemy] Handling detached instances

2014-09-30 Thread Simon King
On Tue, Sep 30, 2014 at 8:52 AM, tonthon wrote: > Hi, > > I'm using dogpile cache to store objects in a redis database, here's the > sample function I use for my tests : > @region.cache_on_arguments() def get_my_model(id): return DBSession().query(Model).get(id) > > I retrieve mo

[sqlalchemy] Handling detached instances

2014-09-30 Thread tonthon
Hi, I'm using dogpile cache to store objects in a redis database, here's the sample function I use for my tests : >>> @region.cache_on_arguments() >>> def get_my_model(id): >>>return DBSession().query(Model).get(id) I retrieve models : >>> model1 = get_my_model(5) >>> model2 = get_my_model(