Database is mysql

I am having a problem with unicode and binary type.

I am using an XML parse the return Unicode strings.

I have a table in mysql with the default character set as utf8

I set the charset to utf8 in the connect string to charset=utf8

I am trying to send a unicode string to the Binary column in the table and
get the following traceback

What does the python side need to be so that the Binary type case accept 
the data.

The line that is failing in the Mysqldb:
def Binary(x):
    return str(x)

SQLAlchemny place:

    def bind_processor(self, dialect):
        DBAPIBinary = dialect.dbapi.Binary
        def process(value):
            if value is not None:
                return DBAPIBinary(value)
            else:
                return None
        return process
 


  File 
"/usr/local/ltcd/lib/SQLAlchemy-0.4.1-py2.5.egg/sqlalchemy/engine/base.py", 
line 789, in execute
    return Connection.executors[c](self, object, multiparams, params)
  File 
"/usr/local/ltcd/lib/SQLAlchemy-0.4.1-py2.5.egg/sqlalchemy/engine/base.py", 
line 840, in execute_clauseelement
    return self._execute_compiled(elem.compile(dialect=self.dialect, 
column_keys=keys, inline=len(params) > 1), distilled_params=params)
  File 
"/usr/local/ltcd/lib/SQLAlchemy-0.4.1-py2.5.egg/sqlalchemy/engine/base.py", 
line 849, in _execute_compiled
    context = self.__create_execution_context(compiled=compiled, 
parameters=distilled_params)
  File 
"/usr/local/ltcd/lib/SQLAlchemy-0.4.1-py2.5.egg/sqlalchemy/engine/base.py", 
line 858, in __create_execution_context
    return self.engine.dialect.create_execution_context(connection=self, 
**kwargs)
  File 
"/usr/local/ltcd/lib/SQLAlchemy-0.4.1-py2.5.egg/sqlalchemy/databases/mysql.py", 
line 1461, in create_execution_context
    return MySQLExecutionContext(self, connection, **kwargs)
  File 
"/usr/local/ltcd/lib/SQLAlchemy-0.4.1-py2.5.egg/sqlalchemy/engine/default.py", 
line 174, in __init__
    self.parameters = 
self.__convert_compiled_params(self.compiled_parameters)
  File 
"/usr/local/ltcd/lib/SQLAlchemy-0.4.1-py2.5.egg/sqlalchemy/engine/default.py", 
line 228, in __convert_compiled_params
    param.append(processors[key](compiled_params[key]))
  File 
"/usr/local/ltcd/lib/SQLAlchemy-0.4.1-py2.5.egg/sqlalchemy/types.py", 
line 440, in process
    return DBAPIBinary(value)
  File "/var/lib/python-support/python2.5/MySQLdb/__init__.py", line 69, 
in Binary
    return str(x)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in 
position 37: ordinal not in range(128)


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to