[reportlab-users] Building Paragraph From Database Record

Rich Shepard rshepard at appl-ecosys.com
Mon Jul 2 12:02:03 EDT 2007

I use pysqlite to retrieve records from database tables and put them in a
list of tuples. I would like to display these values (by row) as a paragraph
within a table cell with the parameter name (in bold) and the parameter
value, and each pair separated by a semi-colon.

For example, a column named 'Variables' would have a cell with contents
like this:

Name: 'Soil depth'; Description: 'Surface through C horizon';
Component: 'Slope stability'; Sub-component: 'None'; Data
source: 'External'; Scale: '0-50'; Method: 'Centroid';

Can I do this with code similar to this;

style = styleSheet['BodyText']
for i in len(range(self.data)):
story.append(Paragraph(label[i], + '; ' +self.data[i]))

if I have the lables also in a list?

In a similar situation, can I use the newline, '\n,' in a single paragraph
combining labels and their values? What I now have is this:

self.data = []
self.data = self.cur.fetchall()

story.append(Paragraph(<b>"Project name: "</b>, self.data(model_name)))
story.append(Paragraph(<b>"Project description: "</b>, self.data(model_desc)))
story.append(Paragraph(<b>"Project type: "</b>, self.data(model_type)))
story.append(Paragraph(<b>"Project owner: "</b>, self.data(proj_owner)))
story.append(Paragraph(<b>"Project location: "</b>, self.data(proj_location)))
story.append(Paragraph(<b>"Project state/province: "</b>, self.data(proj_state)))
story.append(Paragraph(<b>"Lead agency: "</b>, self.data(lead_agency)))
story.append(Paragraph(<b>"Knowledge engineers: "</b>, self.data(keName)))

and I would like to write it as a single story.append(Paragraph...) using
embedded newlines.


Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerator(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

More information about the reportlab-users mailing list