jeudi 7 mai 2015

Python sqlite3 extra character in queries result

So I am trying to run a simple query in python using sqlite to try it out . I get the result of the query right, but I get an extra "u" at the beginning of each text field and I am not sure why. Here is the code:

import sqlite3

db = sqlite3.connect(':memory:')
c = db.cursor()

c.execute("create table Students (ID INTEGER Primary key AUTOINCREMENT, FN text, LN text);")

c.execute("INSERT into Students (FN,LN) Values ('FirstName','LastName');")

c.execute("Select * from Students")

for i in c:
    print(i)

and here is the result I get:

(1, u'FirstName', u'LastName')

Process finished with exit code 0

any clue why this happens ? Thanks

Aucun commentaire:

Enregistrer un commentaire