Well, yeah, OK, it's more than that, but after years of being worn away
by "Post a minimal example" requests on comp.text.tex, a minimal
example is what you got...
<heh> If you were supplying an SQL backup/dump of the schema and
data, yeah...
Thanks for the stuff on LEFT OUTER JOIN. Authorless books would be one
of those things I wouldn't have noticed going astray.
Hopefully you never have to worry about a bookless author said:
I think this goes along with what I thought of immediately after
posting the question: one query to gather all info needed, then
post-process in Python to order it all (so *that's* why I posted
here...). My thoughts had been to turn
[ 1, "Puppetry", "Bill" ]
[ 1, "Puppetry", "Ben" ]
[ 1, "Puppetry", "Flowerpot Men" ]
into
[ 1, "Puppetry", [ "Bill", "Ben", "Flowerpot Men" ] ]
(if that's not overcomplicating it a bit)...
said:
... which appears to be along the lines of what your code does! (Where
Output_Author_Data(bk) could append to the author list of the current
book.
Well, I was sort of focused on your mention of "web page listing"...
I had some old MySQL dump at work (they discovered I had MySQL
running on my desktop and I had to remove it). With some modifications,
I was able to feed the data into SQLite (since SQLite is not a server,
per se, but just a file handler it should be invisible to the corporate
security scans). I then hacked up this little thing:
booklist.py
-=-=-=-=-=-=-=-=-
#
# Simple test using SQLite and a port of test data from MySQL
#
from pysqlite2 import dbapi2 as sqlite
import os
DATABASE = "booklist"
OUTPUT = "booklist.html"
THESELECT = """
select title.ID,
Title,
publisher.Name,
Form,
Last,
First from title
left outer join title_author
on title.ID = Title_ID
join author
on Author_ID = author.ID
join publisher
on Publisher_ID = publisher.ID
join format
on Format_ID = format.ID
order by Title,
title_author.ID
"""
HTMLSTART = """<html>
<head>
<title>Simple Database Retrieval Test</title>
</head>
<body bgcolor="#AAAAAA">
<table width="95%" align="center" frame="box" border="3">
<tr><th>Title</th><th>Publisher</th><th>Format</th><th>Author(s)</th></tr>
"""
html = open(OUTPUT, "w")
html.write(HTMLSTART)
con = sqlite.connect(DATABASE)
crs = con.cursor()
crs.execute(THESELECT)
lastID = None
for row in crs:
(ID, Title, Publisher, Format, Last, First) = row
if lastID != ID:
if lastID:
html.write("</table>\n</td>\n</tr>\n")
html.write("""<tr>
<td>%s</td><td>%s</td><td>%s</td><td>
<table border="0">""" %
(Title, Publisher, Format))
lastID = ID
if Last and First:
html.write("<tr><td>%s, %s</td></tr>\n" %
(Last, First))
elif not Last:
html.write("<tr><td>%s</td></tr>\n" % First)
elif not First:
html.write("<tr><td>%s</td></tr>\n" % Last)
html.write("</table>\n</td>\n</tr>\n</table>\n</body></html>")
html.close()
crs.close()
con.close()
os.startfile(OUTPUT) #windows only
-=-=-=-=-=-=-=-=-=-
It generated the following HTML (hope it isn't too long... Cut and
save everything between the -=-=-=-=-=-=- and save with as some .html
file, then open it in a browser...
-=-=-=-=-=-=-=-=-
<html>
<head>
<title>Simple Database Retrieval Test</title>
</head>
<body bgcolor="#AAAAAA">
<table width="95%" align="center" frame="box" border="3">
<tr><th>Title</th><th>Publisher</th><th>Format</th><th>Author(s)</th></tr>
<tr>
<td>Access Database: Design &
Programming</td><td>O'Reilly</td><td>Soft-cover</td><td>
<table border="0"><tr><td>Roman, Steven</td></tr>
</table>
</td>
</tr>
<tr>
<td>Ada for Software Engineers</td><td>John Wiley &
Sons</td><td>Soft-cover</td><td>
<table border="0"><tr><td>Ben-Ari, M.</td></tr>
</table>
</td>
</tr>
<tr>
<td>Learning Python</td><td>O'Reilly</td><td>Soft-cover</td><td>
<table border="0"><tr><td>Lutz, Mark</td></tr>
<tr><td>Ascher, David</td></tr>
</table>
</td>
</tr>
<tr>
<td>Linux in a
Nutshell</td><td>O'Reilly</td><td>Soft-cover</td><td>
<table border="0"><tr><td>Hekman, Jessica Perry</td></tr>
</table>
</td>
</tr>
<tr>
<td>MySQL Administrator's Guide</td><td>MySQL
Press</td><td>Soft-cover</td><td>
<table border="0"><tr><td>MySQL AB</td></tr>
</table>
</td>
</tr>
<tr>
<td>MySQL Language Reference</td><td>MySQL
Press</td><td>Soft-cover</td><td>
<table border="0"><tr><td>MySQL AB</td></tr>
</table>
</td>
</tr>
<tr>
<td>MySQL Reference Manual</td><td>O'Reilly Community
Press</td><td>Soft-cover</td><td>
<table border="0"><tr><td>Widenius, Michael
"Monty"</td></tr>
<tr><td>Axmark, David</td></tr>
<tr><td>MySQL AB</td></tr>
</table>
</td>
</tr>
<tr>
<td>Programming Perl, 2nd
Edition</td><td>O'Reilly</td><td>Soft-cover</td><td>
<table border="0"><tr><td>Wall, Larry</td></tr>
<tr><td>Christiansen, Tom</td></tr>
<tr><td>Schwartz, Randal L.</td></tr>
</table>
</td>
</tr>
<tr>
<td>Python & XML</td><td>O'Reilly</td><td>Soft-cover</td><td>
<table border="0"><tr><td>Jones, Christopher A.</td></tr>
<tr><td>Drake Jr., Fred L.</td></tr>
</table>
</td>
</tr>
<tr>
<td>Python and Tkinter
Programming</td><td>Manning</td><td>Soft-cover</td><td>
<table border="0"><tr><td>Grayson, John E.</td></tr>
</table>
</td>
</tr>
<tr>
<td>SQL in a
Nutshell</td><td>O'Reilly</td><td>Soft-cover</td><td>
<table border="0"><tr><td>Kline, Kevin</td></tr>
<tr><td>Kline, Daniel</td></tr>
</table>
</td>
</tr>
<tr>
<td>UML in a
Nutshell</td><td>O'Reilly</td><td>Soft-cover</td><td>
<table border="0"><tr><td>Si Alhir, Sinan</td></tr>
</table>
</td>
</tr>
</table>
</body></html>
-=-=-=-=-=-=-=-=-
--