Hey guys i have a question when i use ignore in

db which one is correct

query_insert_users_settings = (
f"INSERT OR IGNORE INTO users_settings\
(chat_id, {query_insert_users_settings_str_fields}) \
VALUES (?, {query_insert_users_settings_str_input})"
)

or

query_insert_users_settings = (
f"INSERT OR IGNORE INTO users_settings\
(chat_id, {query_insert_or_ignore_users_settings_str_fields}) \
VALUES (?, {query_insert_users_settings_str_input})"
)

23 ответов

41 просмотр

This is not really related to bot development

Yohannes- Автор вопроса
Yohannes- Автор вопроса
s0m31 🇷🇺
This is not really related to bot development

You can just ignore it, let the admins decide what to do

Yohannes
I am saving users id to my db

I have a unity game that can be controller from Telegram bot. That doesn't mean I should ask unity questions here

Yohannes- Автор вопроса
Yohannes- Автор вопроса

Can anyone help?

Yohannes
Can anyone help?

Tip: ChatGPT can help you for small doubts like this one and save time 😉

Yohannes- Автор вопроса

What do you want to insert and into which columns? Because I can see the first col chat_id, but the second column is not clear to me

ЅуѕWΟW64
What do you want to insert and into which columns?...

That's what I was talking about: feels like second column is just being placed from a variable, which name he can't choose

This is the general syntax, you can modify according to your needs: - Using F-Strings: table_name = "your_table_name" column1 = "value1" column2 = "value2" sql_query = f"INSERT OR IGNORE INTO {table_name} (column1, column2) VALUES ('{column1}', '{column2}')" - Using the % formatting: table_name = "your_table_name" column1 = "value1" column2 = "value2" sql_query = "INSERT OR IGNORE INTO %s (column1, column2) VALUES ('%s', '%s')" % (table_name, column1, column2) - Paramentrized (?) Queries (works for SQLite, use the above methods for MySQL): import sqlite3 conn = sqlite3.connect('your_database.db') cursor = conn.cursor() table_name = "your_table_name" column1 = "value1" column2 = "value2" sql_query = "INSERT OR IGNORE INTO {} (column1, column2) VALUES (?, ?)".format(table_name) # values need to be a tuple cursor.execute(sql_query, (column1, column2)) conn.commit() conn.close()

Yohannes- Автор вопроса
ЅуѕWΟW64
What do you want to insert and into which columns?...

Its the same but sometimes i get issues when users just send message instead of using /start and then uses /start command (i think this is the issue), and the database gets locked after so i want to know which one is correct to ignore if users is already available on db

Yohannes
Its the same but sometimes i get issues when users...

Are you using SQLite? In my experience, SQLite tends to get db locks more frequently than MySQL

ЅуѕWΟW64
10 prompts / day on the free plan

restriction is for normal users, it can be easily bypassed xD

It is way easier to get openai account rather than bypassing anything

s0m31 🇷🇺
It is way easier to get openai account rather than...

you're in a normal person's list & it's nice but you can't feel how pentesters enjoy their work at that moment to bypass something

Похожие вопросы

Карта сайта