下面是我的代码
from sqlalchemy import create_engine, text
db_connection_string = "mysql+pymysql://dvgrfhodw7c31y4ss9j5:dvgrfhodw7c31y4ss9j5@aws.connect.psdb.cloud/aws.connect.psdb.cloud?charset=utf8mb4"
engine = create_engine(
db_connection_string,
connect_args= {
"ssl": {
"ssl_ca": "/etc/ssl/cert.pem"
}
}
)
with engine.connect(db_connection_string) as conn:
result = conn.execute(text("select * from jobs"))
print(result.all())
得到的错误是这样的sqlalchemy. exe . operationalerror: (pymysql. error . operationalerror) (1045, "用户'dvgrfhodw7c31y4ss9j5'的访问被拒绝")(此错误的背景信息:https://sqlalche.me/e/14/e3q8)
我想连接到行星规模的数据库,但获得访问拒绝
尝试从connect()
呼叫中移除db_connection_string
。通常只有engine.connect()
。您已经在上面的代码行中添加了db_connection_string作为引擎的参数。希望这对你有帮助!
当连接到DataGrip时,您似乎输入了错误的用户名