LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Avery 05259 from mySQL (https://www.linuxquestions.org/questions/linux-software-2/avery-05259-from-mysql-414347/)

dlublink 02-11-2006 07:45 PM

Avery 05259 from mySQL
 
Hey,

I have just purchased a package of Avery 05259 labels and I need to print about 100 unique addresses and 100 identical address (200 total).

The addresses are all in a mySQL database in a simple table where I could do select `addresse` from `addresses` where `final`='y'.

What is the easiest way to get the addresses from my database to the printer in the proper format for the given labels?

Thanks,

David

johnMG 02-12-2006 11:20 AM

I'd write a Python script to get the data out of the db. Maybe something like:
Code:

#!/usr/bin/python

import MySQLdb
connection = MySQLdb.connect( user="some_user", passwd="some_passw0rd", db="my_address_db" )
cursor = connection.cursor()
cursor.execute( 'select * from addresses where final="y"' )
results = cursor.fetchall()
for result in results:
    print result
connection.close()

If you fiddled around with formatting and spaces, you might be able to print
out columns and get it to come out right (a plain text file).

For something fancier though, I'd probably use a pdf library like reportlab
( http://www.reportlab.org/rl_toolkit.html ) to create a pdf on the fly
(instead of just printing out the results as plain text).

Another option might be to have your script spit out html, then convert
that html to a pdf (with some control over how the pdf gets formatted) using
htmldoc ( http://www.easysw.com/htmldoc/ ).

johnMG 02-12-2006 12:11 PM

Or you could produce TeX output, then process that into a pdf using tex2pdf.


All times are GMT -5. The time now is 11:40 PM.