Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8738151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:40:50+00:00 2026-06-13T10:40:50+00:00

I am trying to insert tuple in database. It doesn’t give any error in

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:40:51+00:00Added an answer on June 13, 2026 at 10:40 am

    The u prefix on a string means that it is a Unicode string, you still have a two-element tuple as expected.

    By default the sqlite3 module returns text as Unicode strings. If you want to receive byte strings encoded in utf-8 instead, you can set the connection’s text_factory attribute to str.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the below code, I am trying insert the records from excel to Database
I'm trying to INSERT into a table, but I get the error Cannot add
I was developing a generic linked list. Although the compiler doesn't give any error
Im trying to insert data to my database, and it gives me an error
I'm trying to insert a tuple into a mySQL database in the following manner.
I'm trying to insert some import lines into a python source file, but i
Hi I am trying insert data into the database using prepared statement but I
while trying to insert data i am getting this error 07-29 18:15:19.909: E/sqlite(863): android.database.sqlite.SQLiteException:
im trying to insert data into a particular row in the database, but i
Trying to insert data in database from edittext in android but data is not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.