On Wed, Feb 25, 2009 at 11:39, Gregg Lind <[email protected]> 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 JsonString(types.TypeDecorator):
impl = types.String
def process_result_value(self, value, dialect):
if value is None:
return None
else:
return simplejson.loads(value)
def process_bind_param(self, value, dialect):
if value is None:
return None
else:
return simplejson.dumps(value)
-----------------
[]s
Roger
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---