I have been playing with new types using sqlalchemy and have an error
I do not understand. Table schema and type definition are here:
-----------------------------------------
def generate_uuid():
return uuid.uuid1()
class GUID(sa.types.TypeEngine):
def __init__(self):
pass
def get_col_spec(self):
return "varchar(40)"
def convert_bind_param(self, value, engine):
return str(value)
def convert_result_value(self, value, engine):
return uuid.UUID(value)
t_contacts = sa.Table('contacts',meta.metadata,
sa.Column('id',sa.types.Integer,primary_key=True),
sa.Column('uuid',GUID,default=generate_uuid),
sa.Column('firstname',sa.types.String(32),nullable=False),
sa.Column('lastname',sa.types.String(32),nullable=False),
sa.Column('email',sa.types.String(100),nullable=False),
sa.Column('phone',sa.types.String(32)))
----------------------------------
In a Pylons web app, I get:
<class 'sqlalchemy.exc.ProgrammingError'>: (ProgrammingError) can't
adapt 'INSERT INTO contacts (id, uuid, firstname, lastname, email,
phone) VALUES (%(id)s, %(uuid)s, %(firstname)s, %(lastname)s, %
(email)s, %(phone)s)' {'uuid':
UUID('58d6bcb4-8cc6-11dd-983d-0016cb972e45'), 'firstname': u'Sean',
'lastname': u'Davis', 'email': u'sdavis2 AT mail.nih.gov', 'phone':
u'301-435-2652', 'id': 3L}
What am I missing?
Thanks,
Sean
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---