Mail Merge from python data

Dylan Evans dylan at
Wed Nov 3 09:09:08 CET 2010

On Wed, Nov 3, 2010 at 3:20 PM, Tim Harig <usernet at> wrote:

> This page didn't make it to through to my nntp server so I appologize if I
> miss something that was covered.
> On 2010-11-03, Dennis Lee Bieber <wlfraed at> wrote:
> > On Tue, 2 Nov 2010 20:32:13 +1000, Dylan Evans <dylan at>
> > declaimed the following in gmane.comp.python.general:
> >
> >> I'm setting up a database for an organisation who want to do mail merges
> in
> >> office 2010. I know i can use the MySQL ODBC driver for the mail merge
> but i
> >> have set up the database with lots of relations and many-to-many links
> which
> >> i'm sure will lead to a huge amount of confusion (I think, i don't
> really
> >> know much about mail merge).
> Many to many relationships without some kind of intersection table are
> considered a rather poor practice in general.

Yes an intersection table with a description char field.

> >> What i want to know is, is there anyway to send data from python, which
> the
> >> UI is written in, to office templates and mail merges?
> >
> >       If a long lived form, I'd probably define a query or view (I think
> > MySQL 5.x has output-only views) that isolates just to the data fields
> > used in the mail merge.
> I agree that a view would be the best solution if you have the access to do
> so; but, a couple of other alternatives come to mind in case you do not.
> That would help alot, it would certainly make it easier for then, i didn't
know about views, i will rtfm.

> 1. Do the mail merge in Python using a Word template.  Then you can add any
>        kind of logic that you need to the merge.
> Can this be done in pure python? Bearing in mind that the server will be

> 2. Add some kind of export function to your python UI that allows you to
>        export the data to an Excel sheet, CSV, or even another ODBC data
>        source (like another MySQL table or database that you might have
>        access to).

I have considered this one, ideally the file saving would be skipped, since
it's only temporary and i am concerned that users may save many files mixing
them up, or try to use old export files which are out of sync with the
database. This is a community organisation with volunteers, so i expect
technical competency to be low. However if i can send the data directly from
python to office somehow i could avoid that issue. What would be perfect is
an ODBC driver which connected via XMLRPC or some other simple protocol.

Thanks for the help.


"The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it." - Andrew S. Tanenbaum

"The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it." - Andrew S. Tanenbaum
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list