Skip to content

Improper error shown - (2003, "Can't connect to MySQL server on 'localhost'") #792

@leothewolf

Description

@leothewolf

Describe the bug

Well I formatted my pc and had to reinstall all the stuff and while I started working with my code I started receiving error (2003, "Can't connect to MySQL server on 'localhost'") I was not expecting that as my code worked flawless and at that time my discord bot which uses the same code was up and running well. So after two hours of going through all code I found that I had added db parameter in aiomysql.create_pool and I had forgot to create a database with the db mentioned there so that was the problem! So what I want is it should throw error that db is not found rather than (2003, "Can't connect to MySQL server on 'localhost'")

To Reproduce

I am running latest version of python 3.10 and pip installed aiomysql

Just dont make a database and try creating aiomysql.create_pool object with mentioning db you will get the error!

I used following code:

import asyncio
import aiomysql

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)


async def test_example():
    try:
        conn = await aiomysql.create_pool(host='localhost', port=3306, user='user', password='pass',loop=loop,db="uncreated_db")
    except Exception as e:
        print(e)

loop.run_until_complete(test_example())

Expected behavior

Will throw this error : (2003, "Can't connect to MySQL server on 'localhost'")

Logs/tracebacks

Will throw this error : ``(2003, "Can't connect to MySQL server on 'localhost'")``

Python Version

$ Python 3.10.4

aiomysql Version

$ python -m pip show aiomysql

PyMySQL Version

1.0.2

SQLAlchemy Version

1.0.2

OS

Windows

Database type and version

MySQL : 8.0.29

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpymysql-portAwaiting or implementing port of PyMySQL change

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions