S
S
solid4772021-10-22 15:10:03
Python
solid477, 2021-10-22 15:10:03

Why does SQLLite return a value with quotes?

Good day I use SQLLite, I request data like this:

connection = sqlite3.connect(DB_NAME)
curs = connection.cursor()
curs.execute("SELECT ticker FROM tokens")
symbol_db = curs.fetchall()
print(symbol_db[2])

As a result I get
('Alex',)('Peter',)('Mina',)
but why does he send me the value inside (',)
I need to get the pure value of Alex, Petr, Mina - without these brackets

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jerwright, 2021-10-22
@jerwright

Instead use this:print(symbol_db[2])

for s in symbol_db:
    print(s[2])

V
Vadim, 2021-10-22
@nofail

because fetchall() will return you a list of tuples
https://www.w3schools.com/python/python_tuples.asp
https://www.geeksforgeeks.org/python-convert-list-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question