Answer the question
In order to leave comments, you need to log in
Problems with for and sqlite3, what to do?
Here is a piece, there is a for loop, and it is simply ignored :/
global db
global sql
db = sqlite3.connect("lffdkldf.db", check_same_thread=False)
sql = db.cursor()
sql.execute("""CREATE TABLE IF NOT EXISTS _bot_ (
teleid BIGINT,
NeftCash BIGINT,
reginfo INT
)""")
db.commit()
#command
@bot.message_handler(commands=["start"])
def one(message):
bot.send_message(message.chat.id, "yes", reply_markup = klava1)
#ЭТОТ ЦИКЛ ФОР ПРОСТО НЕ ВЫПОЛНЯТСЯ!
for i in sql.execute("SELECT reginfo FROM _bot_"):
if i[0] == 1:
pass
else:
sql.execute("INSERT INTO _bot_ VALUES(?, ?, ?)",
(message.chat.id, 0, 1))
db.commit()
for i in sql.execute("SELECT teleid FROM _bot_"):
bot.send_message(message.chat.id, i + "all")
Answer the question
In order to leave comments, you need to log in
You would at least read a little bit about working with databases. Or at least look at some examples.
After sql.execute() call sql.fetchall()
I don't have much experience, but I would pass your code like this:
sql.execute("SELECT reginfo FROM _bot_")
data = sql.fetchall()
for i, row in enumerate(data):
# Тут ваш код.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question