E
E
EVG822022-03-06 09:50:37
Python
EVG82, 2022-03-06 09:50:37

How to implement this with Sqlite?

All the best! Some complex examples are googled

Here is an example of code in the executable file so that:

1 user wrote something to the bot.

2 The data was written to the database ID Username the word that the user wrote down.

All this has been preserved.

Another user also wrote to the bot

and a second line with records appeared in the database,

and so on. all of this is preserved.

using the /baza command,

data can be uploaded to csv

. Is there a simple example of this?

found this code:

@dp.message_handler(state=NewPost.email)
async def isValid(message: types.Message, state: FSMContext):
    email = message.text
    await state.update_data(
               {'email': email}
           )

    regex = re.compile(r'([A-Za-z0-9]+[.-_])*[A-Za-z0-9][email protected][A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')

    if re.fullmatch(regex, email):
               print("Valid email")
    try:
                   conn = sqlite3.connect('baza1.db')
                   cur = conn.cursor()
                   cur.execute('CREATE TABLE IF NOT EXISTS baza1(user_id INTEGER, username TEXT, email TEXT)')
                   conn.commit()
    except Exception as e:
                   print(e)
                   conn = sqlite3.connect('baza1.db')
                   cur = conn.cursor()
                   cur.execute('CREATE TABLE IF NOT EXISTS baza1(user_id INTEGER, username TEXT, email TEXT)')
                   conn.commit()


As I understand it, it is connected with the Email entry in the database?

Whereas to fasten it to the input field

after
.....
await message.answer

or better, the simplest example or where specifically about what I need is written.
I know that there are textbooks, but there are not my examples and it is difficult to compare one with the other

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question