Home>

I'm trying to fetch data with fetchall(). Full code:

cursor.execute(f'SELECT exchange_offer_id FROM exchange WHERE exchange_name= "finder"')
exchange= cursor.fetchall()
offers= exchange #all data here
print(offers)

The result looks like this:

[(4,), (3,)]

The data type of the column itself is NUMERIC.

The question is, why does the output show a comma in the value itself? And how can it be removed?

Because this is a tuple of one element, and in the syntax it is always supposed to have a comma in a tuple

andreymal2022-01-25 22:42:13

How to remove -well, for example offers= [x[0] for x in exchange]

andreymal2022-01-25 22:42:13

@andreymal, thank you very much!

SaNoKProG2022-01-25 22:42:13