Thanks for the advice. I pursued the TypeDecorator path, and I'm relatively happy with something along these lines:
class HStoreType(UserDefinedType): """PostgreSQL-specific ``hstore`` storage type.""" python_type = dict def get_col_spec(self): return 'hstore' class DictionaryType(TypeDecorator): """Backend-agnotic dictionary storage type.""" impl = TypeEngine def load_dialect_impl(self, dialect): if dialect.name == 'postgresql': return dialect.type_descriptor(HStoreType()) return dialect.type_descriptor(PickleType()) On Mon, Jul 9, 2012 at 6:36 AM, Michael Bayer <mike...@zzzcomputing.com> wrote: > > with_variant() is a straightforward way to go, you just give any existing > type the per-dialect variants you want: > > mytype = MyHstoreType.with_variant(MyPGHstore, "postgresql") > > if you were using TypeDecorator, you could also add this in using the > load_dialect_impl() method. That's the end effect of with_variant() in any > case (it creates a new TypeDecorator). > > > > On Jul 9, 2012, at 12:38 AM, Jon Parise wrote: > >> I have a simple HStore(UserDefinedType) implementation that works well >> with PostgreSQL. I'd also like to provide a more generic HStore >> implementation that can be used with SQLite for in-memory unit testing >> databases. That fallback implementation could be implemented in terms >> of pickled or JSON-encoded dictionaries. >> >> For my purposes, I'm only interested in bulk dictionary storage. I >> don't need a full hstore implementation complete with query language >> support, etc. >> >> What is the recommended way to expose these two specialized type >> implementations? It looks like the .with_variant() method might be >> helpful here, but the documentation on type variants is slim enough >> that I thought it best to ask here first. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To post to this group, send email to sqlalchemy@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. >> > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalchemy@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. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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.