我正在使用 SQLAlchemy 来管理数据库,并尝试删除所有包含重复项的行。该表有一个 id(主键)和域名。
示例:
ID| 域
1 | example-1.com
2 | example-2.com
3 | example-1.com
在本例中,我想删除 example-1.com 的 1 个实例。有时我需要删除超过 1 个域,但一般来说,数据库不应多次拥有一个域,如果有,则只应保留第一行,而应删除其他行。
我正在尝试使用 Python-Telegram-Bot 发送消息而不等待用户响应,但无法让它工作,并且没有收到任何错误。
Code:
def echo(context):
context.bot.send_message(chat_id=-516017547, text='test')
#chat_id is the group id I found by going to:
#https://api.telegram.org/bot<MY_API>/getUpdates
def main():
updater = Updater(API)
dp = updater.dispatcher
echo_handler = MessageHandler(Filters.text & (~Filters.command), echo)
dp.add_handler(echo_handler)
updater.start_polling()
updater.idle()
main()
Run Code Online (Sandbox Code Playgroud)