I am sorry I did not make it clear.  I am trying to develop new 
application, which requires modern sqlalchemy. New application shares user 
data with old application, so both applications must use same datatype 
declaration.  As old application had used mutable PickleType, So I think I 
can only use PickleType, not MutableList or MutableDict in new application. 
Is there simple ways to  make PickleType mutable in modern sqlalchemy?

On Monday, August 6, 2018 at 10:23:36 PM UTC+8, Mike Bayer wrote:
>
> On Mon, Aug 6, 2018 at 3:09 AM, wei zhang <warcraft...@gmail.com 
> <javascript:>> wrote: 
> > Hi. I have an old application using version 0.7.8,  which  has 
> > 'mutable=True'  in PickleType to make PickleType mutable. I want new 
> > application, which uses new version of sqlalchemy to access the same 
> > database, to be compatible with old application. I can't use MutableList 
> or 
> > MutableSet  in new application because old application doesn't 
> understand 
> > them. 
> > I think the best way is putting back 'mutable=True' to PickleType? Is 
> there 
> > simple ways to do this? 
>
>
> I'm assuming "old application doesnt understand them" means it is 
> still using 0.7.8, and you want that same code to also work with 
> modern SQLAlchemy.     Your "new" application wants to use "import" to 
> use the same code from the "old" application, I assume. 
>
> In the "old" application use version detection: 
>
>
> from sqlalchemy import __version__ 
>
> sqlalchemy_version = tuple([int(x) for x in re.findall(r'(\d+)', 
> __version__)]) 
>
> if sqlalchemy_version < (0, 9): 
>     pickle_type = PickleType(mutable=True) 
> else: 
>    from sqlalchemy.ext.mutable import MutableDict 
>    pickle_type = MutableDict.as_mutable(PickleType()) 
>
> then you just use pickle_type. 
>
>
>
>
>
>
>
>
> > 
> > -- 
> > SQLAlchemy - 
> > The Python SQL Toolkit and Object Relational Mapper 
> > 
> > http://www.sqlalchemy.org/ 
> > 
> > To post example code, please provide an MCVE: Minimal, Complete, and 
> > Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> > description. 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "sqlalchemy" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to sqlalchemy+...@googlegroups.com <javascript:>. 
> > To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to