Python Forum

Full Version: Data pulled from SQL comes in brackets
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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]
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
(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?
(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()