mysqlclient icon indicating copy to clipboard operation
mysqlclient copied to clipboard

Add Path for type of read_default_file connection parametr

Open tonal opened this issue 7 years ago • 1 comments

Sample code:

from pathlib import Path
import MySQLdb

conn = MySQLdb.connect(
    read_default_file=Path(__file__).with_name('mylogin.cnf').resolve())

Error:

Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File "/home/test/projects/venv/lib/python3.6/site-packages/MySQLdb/__init__.py", line 85, in Connect
    return Connection(*args, **kwargs)
  File "/home/test/projects/venv/lib/python3.6/site-packages/MySQLdb/connections.py", line 208, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
TypeError: connect() argument 12 must be str, not PosixPath

tonal avatar Dec 29 '18 05:12 tonal

Only after Python 3.6 but you can use os.fsencode(bytes/str/Path) -> bytes Would have to do it in connections.py

fried avatar Mar 23 '19 01:03 fried