On 01/22/2013 01:16 PM, Carey Gagnon wrote:
Ok...I've done all kind of google searches and still can't find anything close enough to the problem I am having. I know this python specific and not dabo specific but here is my problem if some one can help.I want to call a couple item from each row of a dataset and print the string. The function is used to check for exisiting entries in the database before save. I have this in my bizobj file: def getCurrentProject(self): if self.Record.projectname: projectName = self.Record.projectname projectNameSearch = projectName.split() projectSearchName = projectNameSearch[0] crs = self.getTempCursor() crs.execute("select builderfk, projectname, buildername from projects inner join builders on projects.builderfk = builders.id where projectname like %s", ('%%%s%%' % projectSearchName)) ds = crs.getDataSet() if ds: cnt = len(ds) recs = ds return ("There are %s project similar to %s already in the database as,\n%s.\n\nDo you " "want to add it anyway?" % (cnt, projectName, ", " .join(str(rec["projectrname"]) for rec in recs)) ) This works fine if I just want to return the list of project names, but what I want is a list of projectnames & corresponding buildernames. Everything I try leads to one error or another. How can I call more than one value from each of the dicts within the tuple dataset?
The above works? I am not sure how rec["projectrname"] would find anything? As to your question, try a list comprehension; l = [[rec['projectname'], rec['buildername']] for rec in recs]
Thanks in advance Carey --- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html --- _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/camgtpff58r3tzt3ptmbozc+lq+m0ga2xqfuwtfjgtne9oak...@mail.gmail.com
-- Adrian Klaver [email protected] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[email protected]
