0

I have a problem when i extract values from a DB with sqlite3. Everytime that i extract values ,for example, one number have this format:

[(6,)] 

And is like tuple. I want only the 6 value WITHOUT , and ( and [

Thanks for your help in advanced!

3
  • 1
    what about x = [(6,)] and x[0][0] ? Commented May 11, 2018 at 14:11
  • What statements have you tried? Commented May 11, 2018 at 14:20
  • This is common in scenerio when adapter do not know either number of rows or number of columns to output. I am pretty sure it return a value when we fetch max() of the column in which it knows that there will be only value to output. Commented May 11, 2018 at 14:49

1 Answer 1

1

This is common in all SQL adapters. They always return a list of rows (tuples) even if you only fetchone, it comes back with a tuple, because it doesn't know if this is one value, or one row of values, so to stay constant... tuple.

x[0] is your first row x[0][0] is your first item in that row.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot to all people. An special to eatmeimadinish for the clear explanation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.