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')


The print b results in: 99 Cycling Swords ... which is what I want.

But, the print r.encode('utf-8') leaves the strings as unicode strings eg. u'99 
Cycling Swords'

Any ideas what might be going on?

Dinesh




_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to