Python Forum
Data pulled from SQL comes in brackets - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Data pulled from SQL comes in brackets (/thread-35969.html)



Data pulled from SQL comes in brackets - nickzsche - Jan-04-2022

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]


RE: Data pulled from SQL comes in brackets - buran - Jan-04-2022

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


RE: Data pulled from SQL comes in brackets - nickzsche - Jan-04-2022

(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?


RE: Data pulled from SQL comes in brackets - ibreeden - Jan-04-2022

(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()