def add_randcode(self, code):
with self.connection:
code = self.cursor.execute("SELECT * FROM `subscriptions` WHERE `code` = ?", (code, )).fetchone()
if code == None:
code = random.randint(1000,9999)
self.cursor.execute("""INSERT INTO subscriptions(code)
VALUES (?)""", (code, ))
return code
else:
return code
self.connection.commit()
def add_randcode(self, code):
with self.connection:
code = self.cursor.execute("SELECT * FROM `subscriptions` WHERE `code` = ?", (code, )).fetchone()
if code == None:
code = random.randint(1000,9999)
self.cursor.execute("""INSERT INTO subscriptions(code)
VALUES (?)""", (code, ))
return code
else:
return code
self.connection.commit()
code = self.cursor.execute("SELECT * FROM `subscriptions` WHERE `code` = ?", (code, )).fetchone()
self.cursor.execute("""INSERT INTO subscriptions(code)
VALUES (?)""", (code, ))
а вот так как сделать?