On Sep 19, 2010, at 3:30 AM, Jason Baker wrote: > On Sep 18, 9:08 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: >> You might after that also throw a pdb into the "process_bind_param()" >> method and ensure that its being called > > Sorry, I should have been more clear about this. If I add a print > statement in process_bind_param it doesn't get executed.
Well you'd have to debug some more, your type is fine: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy import types from json import dumps, loads from sqlalchemy.ext.declarative import declarative_base class Json(types.TypeDecorator, types.MutableType): impl=types.Text def process_bind_param(self, value, dialect): return dumps(value) def process_result_value(self, value, dialect): return loads(value) Base = declarative_base() class Content(Base): __tablename__ = 'content' id = Column(Integer, primary_key=True) entity = Column(String(20)) handle_value = Column(String(20)) data = Column(Json) export_date = Column(BigInteger) e = create_engine('mysql://scott:ti...@localhost/test', echo=True) Base.metadata.drop_all(e) Base.metadata.create_all(e) sess = Session(e) c = Content(data={'foo':'bar'}) sess.add(c) sess.commit() output: 2010-09-19 12:42:06,132 INFO sqlalchemy.engine.base.Engine.0x...2ed0 INSERT INTO content (entity, handle_value, data, export_date) VALUES (%s, %s, %s, %s) 2010-09-19 12:42:06,132 INFO sqlalchemy.engine.base.Engine.0x...2ed0 (None, None, '{"foo": "bar"}', None) 2010-09-19 12:42:06,133 INFO sqlalchemy.engine.base.Engine.0x...2ed0 COMMIT > >> and as the ultimate sanity check info default.py do_execute(). > > Could you clarify what you mean by this? Perhaps I'm being a bit > dense. :-/ run the code inside of a try/except, in the except place: import pdb pdb.set_trace() when pdb opens, use the "up" command a few times to get to that stack element, see what's being emitted. But if your Json isn't being run at all then I'm not really sure what would cause that - the type is correct and its applied to the "data" column appropriately. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.