Python Forum
Data pulled from SQL comes in brackets
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Data pulled from SQL comes in brackets
#1
Hello, my data from sql comes in brackets. How can I solve this? I just need the string states inside.


 veritabani = sqlite3.connect("Veritabani.db")
        cursor = veritabani.cursor()
        cursor.execute("""SELECT firma FROM sirketler_tablosu """)
        veriler = cursor.fetchall()
        for i in veriler:
            self.ui.cb_Firmalar.addItem(str(i))
My Program and Datas:
[Image: q4s1crfIPdhSDE6I6AN6hKVrKjRHhAdgeXAU6j-H...authuser=0]

Sqlite My Database:

[Image: aBmwFR5efxD6tQpqMCxS_xspXfVIMYCAtDlPCS4y...authuser=0]
Reply
#2
Each row (i.e. eacj i) in the result is a tuple. You just convert it to str, so it has a brackets (string representation of the tuple). Poor choice of name by the way - use descriptive names, e.g. row
nickzsche likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Jan-04-2022, 02:18 PM)buran Wrote: Each row (i.e. eacj i) in the result is a tuple. You just convert it to str, so it has a brackets (string representation of the tuple). Poor choice of name by the way - use descriptive names, e.g. row

Got it, so don't those brackets get deleted?
Reply
#4
(Jan-04-2022, 02:21 PM)nickzsche Wrote: Got it, so don't those brackets get deleted?
Use a for-loop to iterate over the tuple and print the elements one by one.
for field in received_tuple:
    print(field, end=" "
print()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] [BeautifulSoup] Why does it turn inserted string's brackets into </>? Winfried 0 1,525 Sep-03-2022, 11:21 PM
Last Post: Winfried
  Reading list items without brackets and quotes jesse68 6 4,640 Jan-14-2022, 07:07 PM
Last Post: jesse68
  For Loop and Use of Brackets to Modify Dictionary in Tic-Tac-Toe Game new_coder_231013 7 2,263 Dec-28-2021, 11:32 AM
Last Post: new_coder_231013
  Getting a certain value from inside brackets. LeoT 5 3,025 Mar-01-2021, 03:34 PM
Last Post: buran
  Removing internal brackets from a string Astrikor 4 2,681 Jun-04-2020, 07:54 PM
Last Post: Astrikor
  Taking brackets out of list in print statement pythonprogrammer 3 2,410 Apr-13-2020, 12:25 PM
Last Post: perfringo
  printing a list contents without brackets in a print statement paracelx 1 2,138 Feb-15-2020, 02:15 AM
Last Post: Larz60+
  Dictionnary brackets issue Reldaing 1 1,838 Nov-10-2019, 11:54 PM
Last Post: ichabod801
  how to remove brackets within a list A3G 17 18,279 Oct-16-2016, 02:34 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020