views:

51

answers:

0

Hi, I'm trying to use MSSet datatype in SQL Alchemy

I'm usinge declarative extension, here is the class:

class SMSEmailOption(Base):

    __tablename__ = 'sms_email_options'

    id = Column(Integer, primary_key=True)
    sms_active = Column(Integer)
    email_active = Column(Integer)
    delivery_time = Column(Date)
    days = Column(MSSet("'mon'", "'tue'", "'wed'", "'thu'", "'fri'", "'sat'",
        "'sun'"))

    def __repr__(self):
        return "<SMSEmailOption(%d, %d, '%s', ...)>" % (self.sms_active,
                self.email_active, self.delivery_time)

when I try to run a query on that table I get the following error:

Traceback (most recent call last):
  File "./sms.py", line 68, in ?
    for option in customer_session.query(SMSEmailOption):
  File "/var/lib/python-support/python2.4/sqlalchemy/orm/query.py", line 938, in __iter__
    return self._execute_and_instances(context)
  File "/var/lib/python-support/python2.4/sqlalchemy/orm/query.py", line 941, in _execute_and_instances
    result = self.session.execute(querycontext.statement, params=self._params, mapper=self.mapper, instance=self._refresh_instance)
  File "/var/lib/python-support/python2.4/sqlalchemy/orm/session.py", line 628, in execute
    return self.__connection(engine, close_with_result=True).execute(clause, params or {})
  File "/var/lib/python-support/python2.4/sqlalchemy/engine/base.py", line 844, in execute
    return Connection.executors[c](self, object, multiparams, params)
  File "/var/lib/python-support/python2.4/sqlalchemy/engine/base.py", line 895, in execute_clauseelement
    return self._execute_compiled(elem.compile(dialect=self.dialect, column_keys=keys, inline=len(params) > 1), distilled_params=params)
  File "/var/lib/python-support/python2.4/sqlalchemy/engine/base.py", line 907, in _execute_compiled
    self.__execute_raw(context)
  File "/var/lib/python-support/python2.4/sqlalchemy/engine/base.py", line 916, in __execute_raw
    self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context)
  File "/var/lib/python-support/python2.4/sqlalchemy/engine/base.py", line 958, in _cursor_execute
    self.dialect.do_execute(cursor, statement, parameters, context=context)
  File "/var/lib/python-support/python2.4/sqlalchemy/databases/mysql.py", line 1488, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line 158, in execute
    self.errorhandler(self, TypeError, m)
  File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line 35, in defaulterrorhandler
    raise errorclass, errorvalue
TypeError: str() takes at most 1 argument (5 given)

Any suggestions will be appreciated!

Thanks in advance

Regards Edoardo