E
E
EcoTry2021-05-23 18:26:31
Python
EcoTry, 2021-05-23 18:26:31

How to make a Bot in the database in the id list automatically give the id?

The essence of the question is what is the database there is a cell under id. There is a command to add a user to the database !data add (NAME) (NIC) (DISCORD) (REG DATE) (ID). It is necessary that the id be issued automatically, for example:
('Egor', 'Proper12_pro', 'EpofTry#6230', '21', '23-05-2021 17:09', ID-->'1'),
('Egor ', 'Proper12_pro', 'EpofTry#6230', '21', '23-05-2021 17:09', ID-->'2'),
('Egor', 'Proper12_pro', 'EpofTry#6230' , '21', '23-05-2021 17:09', ID-->'3'),
but id does not need to be written.

@bot.command()
async def data(ctx, *args):
    if len(args) == 0:
        await ctx.send(f'{ctx.author.name}, не хватает агругумента')
    elif args[0] == 'add':
        now = datetime.datetime.now()
        RegTime = now.strftime("%d-%m-%Y %H:%M")
        base.execute('INSERT INTO data VALUES(?, ?, ?, ?, ?, ?)', (args[1], args[2], args[3], args[4], RegTime, "Тут авто id"))
        base.commit()

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yupiter7575, 2021-05-23
@EcoTry

auto increment and primary key add to the column

T
TanderOFF, 2021-05-29
@TanderOFF

I'm sorry, maybe I misunderstood something, but try adding member.id , and then !add .... ping the user

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question