python - 无法使用python从mysql数据库中检索数据
问题描述
我无法从我的数据库中检索数据。我似乎已经尝试了互联网上的每个页面来尝试让它工作。我确信答案非常简单,但作为非编码人员,我只是不知道它是什么。您能给我的任何帮助将不胜感激。
from twilio.twiml.messaging_response import MessagingResponse
from flask_sqlalchemy import SQLAlchemy
import mysql.connector
def main():
cnx = mysql.connector.connect(user='*****', password='****', host='*****.mysql.pythonanywhere-services.com', database='*****$Working')
cursor = cnx.cursor()
resp = MessagingResponse()
query = "select * from messages"
cursor.execute(query)
for i in cursor.fetchall():
resp.message(i)
cursor.close()
cnx.close()
return str(resp)
解决方案
推荐阅读
- memory - 动态加载各种插件的进程中的内存泄漏
- angular - 从共享服务关闭材料对话框
- node.js - 这是一个节点数据库问题。我包括用户模型,但它不包括在结果中
- java - 返回一个类对应的对象
- php - 嗨团队,我的 laravel 路线返回错误代码 404
- c# - Winform - 不是 WPF - ListView 货币和 C# 复选框
- android - AndroidX 和 places:places-compat 给出 ERROR: Manifest merge failed with multiple errors,查看日志
- python - 检查数据框组是否包含提供列表中的子字符串(不区分大小写)
- c# - 在数据表中查找重复项然后比较重复项
- kubernetes - 证书管理器订单处于无效状态