2021-01-08 04:29 阅读 14

WinError 10061

Hello amazing people. I've been struggling with sqlalchemy for a few weeks now trying to get this error fixed but I just can't do it so I've come to the masters for help. Here is the error I am getting.

Command raised an exception: OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on '' ([WinError 10061] No connection could be made because the target machine actively refused it)") (Background on this error at: http://sqlalche.me/e/e3q8)

If you think I'm trying to connect to you'd be DEAD wrong.

main.py engine = sqlalchemy.create_engine(f'mysql+pymysql://{creds.user}:{creds.dbpassword}@{creds.host}/{creds.database}') logging.info('Running remote instance of MariaDB.') Session = sessionmaker(bind=engine)

creds.py host = "" port = "3306" user = "NotMyUsername" dbpassword = "NotMyDBPassword" database = "tagetDB"

I do not have a server set up on my local machine but I used to and the issue was there when the local server was up. This error does not occur on any other projects. I have another project almost exactly the same that has no issue connecting to the remote DB. I also have datagrip from jetbrains that is also able to connect to the remote server. This issue also arises for our other developer as well. Yes port is open. Yes all my information is correct. I hope I've given you all enough information but if not just let me know! 👋


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • weixin_39834281 weixin_39834281 2021-01-08 04:29

    Soooooooooooo.... Now its working. After 2-3 weeks of not working, I submit 1 ticket and it instantly starts working. I'll leave this issue up for you guys if you want to investigate or have more questions for me if you guys want to close it. 🤦‍♂️

    Edit: Seems the issue works for certain queries and breaks for others... I believe its related to this issue https://github.com/Lawouach/WebSocket-for-Python/issues/130 It's working for some but not for all queries.

    点赞 评论 复制链接分享
  • weixin_39875516 weixin_39875516 2021-01-08 04:29

    Hi, It seems that the problem may be in the pymysql side. SQLAlchemy does not handle the connection directly, but uses the specified dbapi.

    Are you able to connect using pymysql directly, without SQLAlchemy?

    点赞 评论 复制链接分享
  • weixin_39834281 weixin_39834281 2021-01-08 04:29

    Interestingly enough, yes I can connect and execute to the database.

    点赞 评论 复制链接分享
  • weixin_39875516 weixin_39875516 2021-01-08 04:29

    I'm not really sure there is anything actionable here without a reproducible case. SQLAlchemy passes the connection information to the underlying dbapi, so connection problems should be investigated in the the dbapi library.

    I'm closing this for now, if you can isolate a reproducible case please feel free to reopen

    点赞 评论 复制链接分享