On Friday 27 March 2009 07:53:06 pm Manoharan Durga wrote:
> I have a SQlite database called salarydata; it has a table called
> stafflist. I want to generate a report to print the departmentwise
> totals of salaries and advances. The department detail for each staff is
> given in a field called ledger.
>
> I modified the Sample Report generated by AppWizard and tried making a
> simple report. The code is given below.
>
> # -*- coding: utf-8 -*-
>
> import datetime
> import decimal
> import dabo
>
> def getLedgerDataSet():
>
> import sqlite3
> conn=sqlite3.connect('/home/manoharan/apps/Salary/db/salarydata')
> crs = conn.cursor()
> crs.execute("select ledger, sum(salary), sum(advance) from
> stafflist GROUP BY ledger")
> #ds = crs.fetchall()
> ds = []
> for staff in crs.fetchall():
> dsentry = "{'ledger': '" + staff[0] + "', "
> dsentry = dsentry + "salarytotal: " + str(staff[1]) + ", "
> dsentry = dsentry + "advancetotal: " + str(staff[2]) + "}, "
> ds.append(dsentry)
> return ds
>
> The dataset is actually generating the correct number of records; that
> is, one record for each of the department that are in the table. But, in
> the report generated, instead of the values, all the fields display a
> message "string indices must be integers".
>
> The expressions used in the report are self.Record['ledger'] and
> self.Record['salarytotal'] and self.Record['advancetotal']
>
> When I changed the str(staff[1]) to just staff[1], I get this error
> message: TypeError: coercing to Unicode: need string or buffer, int found
>
> Can you please let me know what needs to be changed?
I doubt I'm going to be much help because I really don't know the cause of the
error. But here is a SWAG.
I think the reportwriter is looking for a dabo dataset which might not be what
you created. Normally I convert my dicts
myDaboDataSet = dabo.db.dDataSet(tuple(recordsInADict))
I hope that helps.
--
John Fabiani
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message:
http://leafe.com/archives/byMID/[email protected]