Answer the question
In order to leave comments, you need to log in
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()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question