testcontainers / testcontainers-python

Testcontainers is a Python library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.
https://testcontainers-python.readthedocs.io/en/latest/
Apache License 2.0
1.57k stars 284 forks source link

Bug: hardcoded dialect/driver parameter in connection url in mysql container #727

Open nightblure opened 2 hours ago

nightblure commented 2 hours ago

Describe the bug

I find it strange that the dialect or driver parameter is hardcoded here (look screenshot below), because today there are many different methods and drivers for connecting to mysql. If I use something other than pymysql, I get the wrong connection address from the get_connection_url method.

Code: Image

Possible solution

  1. Remove this hardcoded line and leave only mysql://...;
  2. Allow you to pass an optional dialect or driver parameter to the get_connection_url function or the MySqlContainer class initializer. If its value is non-empty, then in the get_connection_url method it will be inserted into the right place in the connection string

To Reproduce

Runtime environment Looks optional for this issue

nightblure commented 2 hours ago

If this solution works, I could do it