import sqlite3
class class1:
def __init__(self):
self.print1()
def print1(self):
con = sqlite3.connect(\'mydb.sqlite\')
cur = con.cursor()
cur.execute(\"
If you need that strings retrieved from your sqlite database be returned as UTF-8 instead of Unicode, set-up your connection accordingly using the text_factory propery:
import sqlite3
class class1:
def __init__(self):
self.print1()
def print1(self):
con = sqlite3.connect('mydb.sqlite')
con.text_factory = str
cur = con.cursor()
cur.execute("select fname from tblsample1 order by fname")
ar=cur.fetchall()
print(ar)
class1()
See this for the details: http://docs.python.org/library/sqlite3.html#sqlite3.Connection.text_factory
That takes care of the "u" in front of your strings. You'll then have to convert your list of tuples to a list:
ar=[r[0] for r in cur.fetchall()]