我可以使用 Psycopg2 库连接到 mysql

Can I connect to mysql using Psycopg2 lib

我在 python 中有一个连接到 postgreSQL 数据库的项目。

该项目有一个连接到其他数据库的模块。连接字符串位于配置文件中。我将其配置为使用 mysql 数据库,如下所示:

database_url = mysql://user:password@localhost/database

一个运行模块我总是得到以下错误:

line 179, in connect connection_factory=connection_factory, async=async) psycopg2.OperationalError: FATAL: password authentication failed for user "tmp" FATAL: password authentication failed for user "user"

我知道与数据库的所有通信都是由 python ORM SQLAlchemy 进行的,并且此 ORM 支持 MySQL 个数据库。

我不知道为什么我会收到 psycopg2 库发送的身份验证错误。

SQLAlchemy 支持不同的方言,通过适当的驱动程序连接到各种数据库。 MySQL 和 PostgreSQL 均受支持。您将使用 psycopg2 连接到 Postgres,例如MySQLdb 连接到 MySQL。您还必须更改连接字符串。

详情请看这里:http://docs.sqlalchemy.org/en/latest/core/engines.html