Thanks for your follow-up answers to my questions (and in the other thread). I am curious about what you said on BLOBs making for poor PKs. Can you elaborate on that and/or point me to something that does? Thanks in advance.
On Thu, May 20, 2010 at 8:06 PM, Michael Bayer <mike...@zzzcomputing.com> wrote: > > On May 20, 2010, at 4:49 PM, Yang Zhang wrote: > >> I defined a TypeDecorator with impl=postgres.PGUuid so that I can work >> with raw UUID bytes (instead of hex strings), but I'd like to make >> this portable to other DBMSs, where i want the impl to be a BLOB. How >> can I do this? The reference docs are pretty sparse here. Thanks in >> advance. > > i'd recommend a VARCHAR for a uuid as they are usually used as primary keys - > BLOBs make very poor primary keys. > > impl is like: > > class GUIDType(TypeDecorator): > impl = sa.CHAR > > def __init__(self): > TypeDecorator.__init__(self, length=16) > > def load_dialect_impl(self, dialect): > if dialect.name == 'sqlite': > return dialect.type_descriptor(sa.CHAR(self.impl.length)) > else: > return dialect.type_descriptor(pg.UUID()) > > def process_bind_param(self, value, dialect): > if value is None: > return value > else: > return str(value) > > def process_result_value(self, value, dialect): > if value is None: > return value > else: > return uuid.UUID(value) > > > > >> -- >> Yang Zhang >> http://yz.mit.edu/ >> >> -- >> 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. >> > > -- > 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. > > -- Yang Zhang http://yz.mit.edu/ -- 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.