我尝试了与这里找到的完全相同的代码。。。 https://github.com/TomMalkin/SimQLe
我不知道如何连接到mysql数据库
from simqle import ConnectionManager
cm = ConnectionManager("connections.yaml")
sql = "SELECT name, age FROM people WHERE category = :category"
params = {"category": 5}
result = cm.recordset(con_name="my-database", sql=sql, params=params)
获取错误:
UnknownConnectionError: Unknown connection my-database
这就是我如何从命令提示符连接到mysql数据库的方法
mysql -h 172.31.84.39 -udba -pXXXX -P 3392
如何写入连接字符串
我通常使用sqlalchemy连接mysql数据库。我已经阅读了您正在使用的SimQLe文档。在SimQLe文档中
是连接到数据库的方法,您应该将登录参数放在名为connections.yaml的yaml文件中
以下是简单的官方文件: https://github.com/TomMalkin/SimQLe#the-connectionsyaml-file
也许您应该在这里更改一些参数:
从文档中可以看出,SimQle是基于SQLAlchemy构建的
也许您可以使用SQLAlchemy的登录参数来连接SimQLe中的数据库。例如:
改为:
官方文件:
https://simqle.readthedocs.io/en/latest/https://docs.sqlalchemy.org/en/14/dialects/mysql.html#module-sqlalchemy.dialects.mysql.pymysqlhttps://docs.sqlalchemy.org/en/14/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc
相关问题 更多 >
编程相关推荐