'Remove specific sign when filtering in Django

I have this query in my views.py

    cardId = request.POST.get('id')
    with connection.cursor() as cursor:
         cursor.execute("SELECT category1_id FROM app_card_tbl WHERE id =%s", [cardId])
         row = cursor.fetchone()
        
         cursor.execute("SELECT name FROM app_category1_tbl WHERE id =%s",[row])
         tab1 = cursor.fetchone()

         print(tab1)

And the output of this when print is

('thisisname',)

All i want is the output should looks like below must remove the `(',) sign it is possible?

thisisname


Solution 1:[1]

The reason this happens is because each record is put in a tuple, even if it contains a single column. You can print the first item with:

print(tab1[0])

or you can unwrap it when fetching the object:

tab1, = cursor.fetchone()
print(tab1)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Willem Van Onsem