开发者

warning in python with MySQLdb

开发者 https://www.devze.com 2022-12-23 01:01 出处:网络
when I use MySQLdb get this message: /var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is dep开发者_高级运维recated from sets import ImmutableSet

when I use MySQLdb get this message:

/var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is dep开发者_高级运维recated from sets import ImmutableSet

I try filter the warning with

import warnings 
warnings.filterwarnings("ignore", message="the sets module is deprecated from sets import ImmutableSet")

but, I not get changes.

any suggestion?

Many thanks.


From python documentation: you could filter your warning this way, so that if other warnings are caused by an other part of your code, there would still be displayed:

import warnings
with warnings.catch_warnings():
    warnings.simplefilter("ignore", DeprecationWarning)
    import MySQLdb
[...]

but as said by Alex Martelli, the best solution would be to update MySQLdb so that it doesn't use deprecated modules.


What release of MySQLdb are you using? I think the current one (1.2.3c1) should have it fixed see this bug (marked as fixed as of Oct 2008, 1.2 branch).

0

精彩评论

暂无评论...
验证码 换一张
取 消