Answer the question
In order to leave comments, you need to log in
Why is data entered into the database with a comma at the beginning?
I need to enter the userid value into the database, but under certain conditions the entry will be different:
cur.execute(
f'''SELECT pasw FROM users WHERE user_id LIKE "{useridlike}"'''
)
pasw = cur.fetchone()[0]
if pasw is None:
cur.execute(
f'''UPDATE users SET pasw = {message.from_user.id} WHERE user_id = "{useridlike}"'''
) # Сохраняем ему в pasw наш userid, при условии, что до этого строка была пустой.
else:
cur.execute(
f'''UPDATE users SET pasw = "{pasw}, {message.from_user.id}" WHERE user_id = "{useridlike}"'''
) # Сохраняем ему в pasw наш userid, при условии, что до этого строка была не пустой.
Answer the question
In order to leave comments, you need to log in
Well, at least because of the comma - "{pasw} , {message.from_user.id}".
And, I apologize for the question, but where do you dig up such guides?
At the very least, it's not pretty. As a maximum - problems with sql-injections
How correctly? Like this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question