Python error using MysqlDb module - sets deprecated

Currently, I get a warning every time I run a Python script that uses MySQLdb:

/var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet 

I would prefer not to interfere with their lib if possible. I am on a Ubuntu server. Does anyone know an easy way to fix this warning?

thanks

UPDATE : Fixed based on the suggestions below and this link: https://bugzilla.redhat.com/show_bug.cgi?id=505611

 import warnings warnings.filterwarnings('ignore', '.*the sets module is deprecated.*', DeprecationWarning, 'MySQLdb') import MySQLdb 
+6
python mysql
source share
3 answers

Do this before importing the mysql module

 import warnings warnings.filterwarnings(action="ignore", message='the sets module is deprecated') import sets 
+6
source share

You can ignore the warning using warnings or the -W argument to Python. Do not ignore all DeprecationWarnings , but only those from MySQLdb :)

+1
source share

All this means that the sets module (more precisely, the immutableset part) is out of date, and you must use its replacement, install. The kit is built-in, so there is no need to import.

If you need an immutable set, frozenset () should work.

0
source share

All Articles