Re: [Sqlalchemy-tickets] [sqlalchemy] #1608: SQLite does not handle binary strings
Brought to you by:
zzzeek
From: sqlalchemy <mi...@zz...> - 2009-11-06 23:11:02
|
#1608: SQLite does not handle binary strings --------------------------------+------------------------------------------- Reporter: guest | Owner: zzzeek Type: defect | Status: closed Priority: medium | Milestone: Component: sqlite | Severity: no triage selected yet Resolution: worksforme | Keywords: Status_field: awaiting triage | --------------------------------+------------------------------------------- Comment (by zzzeek): sure build your own type using `TypeEngine`. Or build a `TypeDecorator` that implements `load_dialect_impl`, here's one i use for uuids: {{{ 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(PGUuid()) 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) }}} -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/1608#comment:6> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |