> > Message: 1 > Date: Mon, 14 Apr 2008 01:31:41 -0700 > From: "Dinesh B Vadhia" <[EMAIL PROTECTED]> > Subject: [Tutor] encode unicode strings from pysqlite > To: <tutor@python.org> > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > > Here is a program that SELECT's from a pysqlite database table and encode's > the returned unicode strings: > > import sys > import os > import sqlite3 > > con = sqlite3.connect("testDB.db") > cur = con.cursor() > > a = u'99 Cycling Swords' > b = a.encode('utf-8') > print b > > q = '%wor%' > limit = 25 > query = "SELECT fieldB FROM testDB WHERE fieldB LIKE '%s' LIMIT '%s'" %(q, > limit) > for row in cur.execute(query): > r = str(row) > print r.encode('utf-8')
Why not change this to: > for row in cur.execute(query): > for item in row: > print item.encode('utf-8') which will return a string ? Kinuthia. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor