[Mailman-Users] Mailman MySQL backend migration question

Mark Sapiro mark at msapiro.net
Thu Jul 7 03:43:06 CEST 2011

kphamilton wrote:
>I am attempting to migrate from using Mailman's flat file to store
>information about members towards a MySQL database backend instead. I have
>successfully configured it so that when I add a new member or change a
>member, it changes appropriately with the database table. The problem is
>that I have 1500+ people who already exist within the flat file and have
>preferences stored in that file. I need to migrate the data from the flat
>file to the mySQL database so that all of the preferences are preserved.

I am guessing that by 'flat file' you mean membership data as stored in
the list object by the default OldStyleMemberships.py member adaptor.

>I have looked a little bit into .json files and importing the information in
>that manner, but I have not found a solution that works for me. 
>Does anyone have any advice for me on this one?

Again, assuming you have done this in the 'normal' way and have
implemented a replacement MemberAdaptor such as one of the
MysqlMemberships.py MemberAdaptors from
<http://www.orenet.co.uk/opensource/> or
<http://trac.rezo.net/trac/rezo/browser/Mailman>, I suggest you create
a withlist script similar to the following outline.

from Mailman import mm_cfg
from Mailman import OldStyleMemberships as OSM

def move_members(mlist):
    if not mlist.Locked():
    for member in OSM.getMembers(mlist):
        if mlist.isMember(member):
        cpmember = OSM.getMemberCPAddress(mlist, member)
        digest = OSM.getMemberOption(mlist, member, mm_cfg.Digests)
        password = OSM.getMemberPassword(mlist, member)
        language = OSM.getMemberLanguage(mlist, member)
        realname = OSM.getMemberName(mlist, member)
        mlist.addNewMember(cpmember, digest=digest, password=password,
                           language=language, realname=realname)
                                OSM.getDeliveryStatus(mlist, member))
        for flag in (mm_cfg.DontReceiveOwnPosts,
            mlist.setMemberOption(member, flag,
                            OSM.getMemberOption(mlist, member, flag))
                              OSM.getMemberTopics(mlist, member))
        OSM.removeMember(mlist, member)

The above intentionally does not move bounce_info, but could if desired.

The OSM.removeMember(mlist, member) is optional and assumes that none
of this data is used. If you don't do it, the list's config.pck will
still retain all this information which unnecessarily increases its
size an potentially causes confusion

The script isn't too robust. Probably at a minimum, everything from for
member ... through mlist.Save() should be in a try: finally: with the
mlist.Unlock() in the finally:.

Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

More information about the Mailman-Users mailing list