Try to guess the location of the default mysql socket file.
()
| 111 | |
| 112 | |
| 113 | def guess_socket_location() -> str | None: |
| 114 | """Try to guess the location of the default mysql socket file.""" |
| 115 | socket_dirs = filter(os.path.exists, DEFAULT_SOCKET_DIRS) |
| 116 | for directory in socket_dirs: |
| 117 | for r, dirs, files in os.walk(directory, topdown=True): |
| 118 | for filename in files: |
| 119 | name, ext = os.path.splitext(filename) |
| 120 | if name.startswith("mysql") and name != "mysqlx" and ext in (".socket", ".sock"): |
| 121 | return os.path.join(r, filename) |
| 122 | dirs[:] = [d for d in dirs if d.startswith("mysql")] |
| 123 | return None |