Converting List of Tuples to List of Strings

Rich Shepard <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
   I'm stuck in a rut and have not found a way out.

   Records are retrieved from a sqlite table and stored in a list. In another
module (and function) I retrieve these records and want to use their
contents with other data in a different table.

   When I access the data, e.g., 'print appData.polEco' I see this:

[(u'Jobs',), (u'Infrastructure',), (u'Housing',), (u'Tax Base',), (u'Traffic
Volume',), (u'Roads',), (u'Medical care',), (u'Sustainability',)]

   I can extract each tuple, for i in range(len(appData.polEco)), and this
gives me a list of individual tuples:

(u'Jobs',)
(u'Infrastructure',)
(u'Housing',)
(u'Tax Base',)
(u'Traffic Volume',)
(u'Roads',)
(u'Medical care',)
(u'Sustainability',)

   Then, when I want to use these with other data:

values = ('eco', appData.polEco[i], ecoVec[i])
appData.cur.execute("insert or replace into importance (cat, comp, imp_wt)
values (?,?,?)", values)

   python responds:

pysqlite2.dbapi2.InterfaceError: Error binding parameter 1 - probably
unsupported type.

   Printing values gives:

('eco', (u'Roads',), 0.073969887301348305)

   so I assume it's the extra parentheses and unicode mark causing the
problem. But, I've not been able to remove them when I've tried to slice
them off.

   How do I handle this?

Rich

-- 
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.