python - 使用 tableq sqlite 时出错。该怎么办?
问题描述
我有这样的代码:
def pay (message):
token = config.CONFIG ['qiwi']
phone = config.CONFIG ['phone']
db = sqlite3.connect ('users.db')
cursor = db.cursor ()
cursor.execute ("" "CREATE TABLE IF NOT EXISTS users (
user_id TEXT,
qrule TEXT,
cash INTEGER,
usersinbot INTEGER,
pay TEXT,
pay_money INTEGER
) "" ")
price = message.text
api = QApi (token = token, phone = phone)
if not price.isdigit ():
client.send_message (message.chat.id, 'Please enter a valid value')
main (message)
return
price = int (price)
comment = api.bill (price)
cursor.execute (f "UPDATE users SET pay = {str (comment)} WHERE user_id = '{message.chat.id}'")
db.commit ()
cursor.execute (f "UPDATE users SET pay_money = {price} WHERE user_id = '{message.chat.id}'")
db.commit ()
markup_inline = types.InlineKeyboardMarkup ()
item_pay = types.InlineKeyboardButton (text = 'Pay', url = 'link_to_pay')
item_check = types.InlineKeyboardButton (text = 'Check payment', callback_data = 'check')
item_back = types.InlineKeyboardButton (text = 'Back', callback_data = 'bck')
markup_inline.add (item_pay)
markup_inline.add (item_check)
markup_inline.add (item_back)
client.send_message (message.chat.id, f'To proceed to payment, click the pay button and leave the code in the comments for the payment: {comment}. If you do not leave the code, the bot will not accept the payment. In the amount for payment, indicate the same number what you posted earlier. ', reply_markup = markup_inline)
注释变量存储一个用于使用 kiwi api 的令牌。示例令牌 - 901ecc36-82fd-46ba-8792-9f40abe01319
当我执行支付功能时,我得到了错误:
Traceback (most recent call last):
File "c:/Users/Дом/Desktop/Py/PY/tg_bot_frilance/main.py", line 369, in <module>
client.polling(none_stop=True, interval=0)
File "C:\Users\Дом\AppData\Local\Programs\Python\Python38\lib\site-packages\telebot\__init__.py", line 619, in polling
self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout, allowed_updates)
File "C:\Users\Дом\AppData\Local\Programs\Python\Python38\lib\site-packages\telebot\__init__.py", line 678, in __threaded_polling
raise e
File "C:\Users\Дом\AppData\Local\Programs\Python\Python38\lib\site-packages\telebot\__init__.py", line 641, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\Дом\AppData\Local\Programs\Python\Python38\lib\site-packages\telebot\util.py", line 130, in raise_exceptions
raise self.exception_info
File "C:\Users\Дом\AppData\Local\Programs\Python\Python38\lib\site-packages\telebot\util.py", line 82, in run
task(*args, **kwargs)
File "c:/Users/Дом/Desktop/Py/PY/tg_bot_frilance/main.py", line 99, in pay
cursor.execute(f"UPDATE users SET pay = {str(comment)} WHERE user_id = '{message.chat.id}'")
sqlite3.OperationalError: unrecognized token: "472f"
为什么我会得到它,我该如何解决?
解决方案
推荐阅读
- excel - 如果它的值在vba中大于0,则与括号一起颜色字符串
- python - tensorflow.keras:evaluate_generator 与 predict_generator 不同的结果/准确性
- android - 奇怪的旋转行为。活动在轮换后更新,但没有调用任何标准活动生命周期方法
- python - 在多个 excel 电子表格上重复 df.reindex
- python - 使用时出现错误信息:groupby('').transform(pd.rolling_sum, window=30)
- excel - 我可以使用 VBA 让 Excel 忘记它跟随超链接吗?
- react-native - React-native:在两行显示内容
- javascript - 多个模块名称仅在套管警告中不同
- html - 我无法将 LI 项目居中
- javascript - 删除 Firestore 中的嵌套引用