Skip to content

Commit 87ee03b

Browse files
committed
Use keyword only argument for constructor.
1 parent 8ccda4a commit 87ee03b

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

pymysql/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,7 @@ def Binary(x):
110110
return bytes(x)
111111

112112

113-
def Connect(*args, **kwargs):
114-
return connections.Connection(*args, **kwargs)
115-
116-
117-
Connect.__doc__ = connections.Connection.__init__.__doc__
113+
Connect = connect = Connection = connections.Connection
118114

119115

120116
def get_client_info(): # for MySQLdb compatibility
@@ -124,8 +120,6 @@ def get_client_info(): # for MySQLdb compatibility
124120
return ".".join(map(str, version))
125121

126122

127-
connect = Connection = Connect
128-
129123
# we include a doctored version_info here for MySQLdb compatibility
130124
version_info = (1, 4, 0, "final", 0)
131125

pymysql/connections.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class Connection:
120120
See converters.
121121
:param use_unicode:
122122
Whether or not to default to unicode strings.
123-
This option defaults to true for Py3k.
123+
This option defaults to true.
124124
:param client_flag: Custom flags to send to MySQL. Find potential values in constants.CLIENT.
125125
:param cursorclass: Custom cursor class to use.
126126
:param init_command: Initial SQL statement to run when connection is established.
@@ -164,12 +164,13 @@ class Connection:
164164

165165
def __init__(
166166
self,
167-
host=None,
168167
user=None,
169168
password="",
169+
host=None,
170170
database=None,
171-
port=0,
171+
*,
172172
unix_socket=None,
173+
port=0,
173174
charset="",
174175
sql_mode=None,
175176
read_default_file=None,
@@ -179,13 +180,8 @@ def __init__(
179180
cursorclass=Cursor,
180181
init_command=None,
181182
connect_timeout=10,
182-
ssl=None,
183183
read_default_group=None,
184-
compress=None,
185-
named_pipe=None,
186184
autocommit=False,
187-
db=None,
188-
passwd=None,
189185
local_infile=False,
190186
max_allowed_packet=16 * 1024 * 1024,
191187
defer_connect=False,
@@ -196,16 +192,25 @@ def __init__(
196192
binary_prefix=False,
197193
program_name=None,
198194
server_public_key=None,
195+
ssl=None,
199196
ssl_ca=None,
200197
ssl_cert=None,
201198
ssl_disabled=None,
202199
ssl_key=None,
203200
ssl_verify_cert=None,
204201
ssl_verify_identity=None,
202+
compress=None, # not supported
203+
named_pipe=None, # not supported
204+
passwd=None, # deprecated
205+
db=None, # deprecated
205206
):
206207
if db is not None and database is None:
208+
warnings.warn("'db' is deprecated, use 'database'", DeprecationWarning, 3)
207209
database = db
208210
if passwd is not None and not password:
211+
warnings.warn(
212+
"'passwd' is deprecated, use 'password'", DeprecationWarning, 3
213+
)
209214
password = passwd
210215

211216
if compress or named_pipe:

0 commit comments

Comments
 (0)