Answer the question
In order to leave comments, you need to log in
Python sql select returns None. Why?
Good day. I know this has been asked, but I can't seem to solve the problem.
Here is the code:
sql_select = "SELECT telegram_user_id FROM users"
sql_select = db.cursor(buffered=True).execute(sql_select)
print(sql_select)
if message.from_user.id not in sql_select:
sql_insert = "INSERT INTO users ('что-то') VALUES (%s)"
val = (['что-то'])
db.cursor().execute(sql_insert, val)
await message.answer("Вы не были до зарегистрированы, поэтому мы занесли в базу данных")
db.commit()
if message.from_user.id not in sql_select:
TypeError: argument of type 'NoneType' is not iterable
Answer the question
In order to leave comments, you need to log in
Try like this
sql_select = "SELECT telegram_user_id FROM users"
cursor = db.cursor(buffered=True)
cursor.execute(sql_select)
result = cursor.fetchall()
print(result)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question