Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Path for type of read_default_file connection parametr #319

Open
tonal opened this issue Dec 29, 2018 · 1 comment
Open

Add Path for type of read_default_file connection parametr #319

tonal opened this issue Dec 29, 2018 · 1 comment

Comments

@tonal
Copy link

tonal commented Dec 29, 2018

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
@fried
Copy link
Contributor

fried commented Mar 23, 2019

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

@methane methane added this to the v2.0 milestone Nov 18, 2019
@methane methane removed this from the v2.0 milestone Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants