Peteris Krumins wrote:
> I am not using Unicode type anywhere, all the columns the warnings
> originate from are String.
>
> Here is one example when the warnings occur. The table is 'downloads':
>
> downloads_table = Table('downloads', metadata,
>     Column('download_id',   Integer,    primary_key=True),
>     Column('title',         String(128)),
>     Column('filename',      String(128)),
>     Column('mimetype',      String(64)),
>     Column('timestamp',     DateTime),
>     Column('downloads',     Integer),
>     mysql_charset='utf8'
> )
>
> And it has the corresponding Download class mapped to it.
>
> Here is a code fragment that produces the warnings:
>
>>>> from xyzzy.models import Download, session
>>>> d = Download('file title', 'file_title.txt', 'text/plain')
>>>> session.add(d)
>>>> session.commit()
> /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/
> sqlalchemy/engine/default.py:472: SAWarning: Unicode type received non-
> unicode bind param value 'file title'
>   param.append(processors[key](compiled_params[key]))
> /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/
> sqlalchemy/engine/default.py:472: SAWarning: Unicode type received non-
> unicode bind param value 'file_title.txt'
>   param.append(processors[key](compiled_params[key]))
> /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/
> sqlalchemy/engine/default.py:472: SAWarning: Unicode type received non-
> unicode bind param value 'text/plain'
>   param.append(processors[key](compiled_params[key]))
>
>
> I looked into it a bit more and noticed that I have "convert_unicode"
> parameter for create_engine() set.
>
> engine = create_engine(
>     config['database_uri'],
>     convert_unicode=True,
>     echo=config['database_echo'],
>     pool_recycle=3600
> )
>
> I removed "convert_unicode=True" and I don't get any warnings anymore.
>
>
> Any comments?

just that the behavior is documented here:

http://www.sqlalchemy.org/docs/reference/sqlalchemy/connections.html?highlight=create_engine#sqlalchemy.create_engine

its generally not a recommended practice to use convert_unicode with
create_engine, and better to use the Unicode type specifically in those
places where you'd want to accommodate non-ascii strings.



>
>
> Sincerely,
> P.Krumins
>
>
>
>
> On Apr 1, 5:35 am, Michael Bayer <mike...@zzzcomputing.com> wrote:
>> would have to see how you've set things up in order for that to occur.  
>> If you use the Unicode type with default settings, the behavior is the
>> same on 0.5 and 0.6 - Python unicodes are expected and a warning is
>> emitted otherwise.  With String,VARCHAR, CHAR, etc., this is not the
>> case and plain strings can be passed without warning.
>>
>> On Mar 31, 2010, at 5:59 PM, Peteris Krumins wrote:
>>
>> > Hi all,
>>
>> > I upgraded to SA 0.6beta3 and suddenly I am getting a lot of
>> > "SAWarning: Unicode type received non-unicode bind param value"
>> > warnings for the code that worked OK on 0.5.x. The warnings occur even
>> > for values that are plain ascii (no code points above 127).
>>
>> > Does it mean I'll have to make sure my code uses Python unicode
>> > strings everywhere, even if it they are ascii?
>>
>> > Here are some of the warnings:
>>
>> > /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/
>> > sqlalchemy/dialects/mysql/base.py:960: SAWarning: Unicode type
>> > received non-unicode bind param value '1'
>>
>> > /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/
>> > sqlalchemy/engine/default.py:472: SAWarning: Unicode type received
>> non-
>> > unicode bind param value 'application/pdf'
>>
>> > /xyzzy/lib/python2.5/site-packages/SQLAlchemy-0.6beta3-py2.5.egg/
>> > sqlalchemy/engine/default.py:472: SAWarning: Unicode type received
>> non-
>> > unicode bind param value '1fd67ac4162561def609a4862677cdbc'
>>
>> > Sincerely,
>> > P.Krumins
>>
>> > --
>> > 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
>> athttp://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.
>
>

-- 
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.

Reply via email to