I am trying to insert tuple in database. It doesn't give any error in the code. But the output contains some dummy character while printing the whole row. Output is also copied in the post. Please help me in figuring out the bug in the code. This is a dummy code for a big project.
Code:
import sqlite3 as sql
def foo():
db = sql.connect('test.db')
db.execute('drop table if exists test')
db.execute('create table test (t1 text, i1 int)')
str = """insert into test(t1,i1) values ('one',1 ) """
db.execute(str)
db.execute('insert into test(t1,i1) values (?, ?)', ('two',2))
db.commit()
cursor = db.execute('select * from test')
for row in cursor:
print row
Output:
(u'one', 1)
(u'two', 2)
As shown in the output, The expected output of the code is the a tuple of two elements. Instead there is some character 'u' in the output.
Thanks