[sqlalchemy] Re: export and import JSON from database (JSON type)

2009-03-02 Thread eLuke
On Feb 28, 10:50 am, Michael Bayer mike...@zzzcomputing.com wrote: A method like this would work: def from_json(self,json): json_obj = simplejson.loads(json) for k, v in json_obj.values(): setattr(self, k, v) if you're concerned about dates you can use a date-based

[sqlalchemy] Re: export and import JSON from database (JSON type)

2009-02-28 Thread eLuke
On Feb 25, 12:17 pm, Roger Demetrescu roger.demetre...@gmail.com wrote: Note that this implementation is very simple. Depending of your use case, you probably should take a look at MutableType [1] and types.TypeEngine.is_mutable(). [1]

[sqlalchemy] Re: export and import JSON from database (JSON type)

2009-02-28 Thread Michael Bayer
On Feb 27, 2009, at 11:24 PM, eLuke wrote: I have a simple model/class named Comment with columns id (int), comment (text), and postdate (datetime). Below are the main bits of the python code I'm using to test how I should handle this: # json from the client's browser json =

[sqlalchemy] Re: export and import JSON from database (JSON type)

2009-02-25 Thread Roger Demetrescu
On Wed, Feb 25, 2009 at 11:39, Gregg Lind gregg.l...@gmail.com wrote: How does one create a TypeDecorator to export and import JSON to a database using SA? I did something like that recently: - from sqlalchemy import types import simplejson class

[sqlalchemy] Re: export and import JSON from database (JSON type)

2009-02-25 Thread Gregg Lind
Thank you, that's simpler than my attempts, for sure! On Wed, Feb 25, 2009 at 10:27 AM, Roger Demetrescu roger.demetre...@gmail.com wrote: On Wed, Feb 25, 2009 at 11:39, Gregg Lind gregg.l...@gmail.com wrote: How does one create a TypeDecorator to export and import JSON to a database

[sqlalchemy] Re: export and import JSON from database (JSON type)

2009-02-25 Thread Roger Demetrescu
On Wed, Feb 25, 2009 at 13:40, Gregg Lind gregg.l...@gmail.com wrote: Thank you, that's simpler than my attempts, for sure! You're welcome. Note that this implementation is very simple. Depending of your use case, you probably should take a look at MutableType [1] and