Sqlite3 aiogram перезаписывает столбец в базе данных если человек уже там есть, а мне нужно что-бы бд записывала в новую строчку
помогите пожалуйста Sqlite3 aiogram перезаписывает строчку в базе данных если человек уже там есть, а мне нужно что-бы бд записывала в новую строчку.
db = sqlite3.connect("mercury.db")
cur = db.cursor()
db.row_factory = lambda cursor, row: row[0]
c = db.cursor()
c.execute(
'create table if not exists chat(id primary key ,number, user , nick , first_name, last_name , country, data)')
@dp.message_handler(commands=["register"])
async def ggssd(message: types.Message):
phone = types.ReplyKeyboardMarkup(selective=True)
b1 = types.KeyboardButton(text="Зарегистрироваться", request_contact=True)
phone.add(b1)
await bot.send_message(message.chat.id, f'Чтобы продолжить Регистрацию вам необходимо, Нажать кнопку Зарегистрироваться',
parse_mode="Markdown", reply_markup=phone)
c.execute("select * from chat")
try:
c.execute("insert into chat values(? ,? ,? ,? ,? ,? ,? , ?)", (
message.chat.id, message.contact.phone_number, "@" + str(message.chat.username), message.chat.first_name,
None,
None, None, None))
db.commit()
except:
c.execute("update chat set number == ? where id == ?", (message.contact.phone_number, message.chat.id))
c.execute("select * from chat")
c.execute("update chat set first_name == ? where id == ?", (str(hname), message.chat.id)).fetchone()
db.commit()
c.execute("update chat set last_name == ? where id == ?", (str(kname), message.chat.id)).fetchone()
db.commit()
c.execute("update chat set data == ? where id == ?", (str(datayr), message.chat.id)).fetchone()
db.commit()
c.execute("update chat set country == ? where id == ?", (str(cook), message.chat.id)).fetchone()
db.commit()
gh = 0