Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 66029d6

Browse filesBrowse files
committed
Support 'database' and 'password' kwargs
1 parent d505521 commit 66029d6
Copy full SHA for 66029d6

File tree

Expand file treeCollapse file tree

2 files changed

+67
-91
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+67
-91
lines changed

‎MySQLdb/connections.py

Copy file name to clipboardExpand all lines: MySQLdb/connections.py
+65-83Lines changed: 65 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -76,89 +76,66 @@ def __init__(self, *args, **kwargs):
7676
that you only use keyword parameters. Consult the MySQL C API
7777
documentation for more information.
7878
79-
host
80-
string, host to connect
81-
82-
user
83-
string, user to connect as
84-
85-
passwd
86-
string, password to use
87-
88-
db
89-
string, database to use
90-
91-
port
92-
integer, TCP/IP port to connect to
93-
94-
unix_socket
95-
string, location of unix_socket to use
96-
97-
conv
98-
conversion dictionary, see MySQLdb.converters
99-
100-
connect_timeout
101-
number of seconds to wait before the connection attempt
102-
fails.
103-
104-
compress
105-
if set, compression is enabled
106-
107-
named_pipe
108-
if set, a named pipe is used to connect (Windows only)
109-
110-
init_command
111-
command which is run once the connection is created
112-
113-
read_default_file
114-
file from which default client values are read
115-
116-
read_default_group
117-
configuration group to use from the default file
118-
119-
cursorclass
120-
class object, used to create cursors (keyword only)
121-
122-
use_unicode
123-
If True, text-like columns are returned as unicode objects
124-
using the connection's character set. Otherwise, text-like
125-
columns are returned as strings. columns are returned as
126-
normal strings. Unicode objects will always be encoded to
127-
the connection's character set regardless of this setting.
128-
Default to False on Python 2 and True on Python 3.
129-
130-
charset
131-
If supplied, the connection character set will be changed
132-
to this character set (MySQL-4.1 and newer). This implies
133-
use_unicode=True.
134-
135-
sql_mode
136-
If supplied, the session SQL mode will be changed to this
137-
setting (MySQL-4.1 and newer). For more details and legal
138-
values, see the MySQL documentation.
139-
140-
client_flag
141-
integer, flags to use or 0
142-
(see MySQL docs or constants/CLIENTS.py)
143-
144-
ssl
145-
dictionary or mapping, contains SSL connection parameters;
146-
see the MySQL documentation for more details
147-
(mysql_ssl_set()). If this is set, and the client does not
148-
support SSL, NotSupportedError will be raised.
149-
150-
local_infile
151-
integer, non-zero enables LOAD LOCAL INFILE; zero disables
152-
153-
autocommit
154-
If False (default), autocommit is disabled.
155-
If True, autocommit is enabled.
156-
If None, autocommit isn't set and server default is used.
157-
158-
waiter
159-
Callable accepts fd as an argument. It is called after sending
160-
query and before reading response.
161-
This is useful when using with greenlet and async io.
79+
:param str host: host to connect
80+
:param str user: user to connect as
81+
:param str password: password to use
82+
:param str passwd: alias of password, for backward compatibility
83+
:param str database: database to use
84+
:param str db: alias of database, for backward compatibility
85+
:param int port: TCP/IP port to connect to
86+
:param str unix_socket: location of unix_socket to use
87+
:param dict conv: conversion dictionary, see MySQLdb.converters
88+
:param int connect_timeout:
89+
number of seconds to wait before the connection attempt fails.
90+
91+
:param bool compress: if set, compression is enabled
92+
:param str named_pipe: if set, a named pipe is used to connect (Windows only)
93+
:param str init_command:
94+
command which is run once the connection is created
95+
96+
:param str read_default_file:
97+
file from which default client values are read
98+
99+
:param str read_default_group:
100+
configuration group to use from the default file
101+
102+
:param type cursorclass:
103+
class object, used to create cursors (keyword only)
104+
105+
:param str use_unicode:
106+
If True, text-like columns are returned as unicode objects
107+
using the connection's character set. Otherwise, text-like
108+
columns are returned as strings. columns are returned as
109+
normal strings. Unicode objects will always be encoded to
110+
the connection's character set regardless of this setting.
111+
Default to False on Python 2 and True on Python 3.
112+
113+
:param str charset:
114+
If supplied, the connection character set will be changed
115+
to this character set (MySQL-4.1 and newer). This implies
116+
use_unicode=True.
117+
118+
:param str sql_mode:
119+
If supplied, the session SQL mode will be changed to this
120+
setting (MySQL-4.1 and newer). For more details and legal
121+
values, see the MySQL documentation.
122+
123+
:param int client_flag:
124+
flags to use or 0 (see MySQL docs or constants/CLIENTS.py)
125+
126+
:param dict ssl:
127+
dictionary or mapping contains SSL connection parameters;
128+
see the MySQL documentation for more details
129+
(mysql_ssl_set()). If this is set, and the client does not
130+
support SSL, NotSupportedError will be raised.
131+
132+
:param bool local_infile:
133+
enables LOAD LOCAL INFILE; zero disables
134+
135+
:param bool autocommit:
136+
If False (default), autocommit is disabled.
137+
If True, autocommit is enabled.
138+
If None, autocommit isn't set and server default is used.
162139
163140
There are a number of undocumented, non-standard methods. See the
164141
documentation for the MySQL C API for some hints on what they do.
@@ -169,6 +146,11 @@ class object, used to create cursors (keyword only)
169146

170147
kwargs2 = kwargs.copy()
171148

149+
if 'database' in kwargs2:
150+
kwargs2['db'] = kwargs2.pop('database')
151+
if 'password' in kwargs2:
152+
kwargs2['passwd'] = kwargs2.pop('password')
153+
172154
if 'conv' in kwargs:
173155
conv = kwargs['conv']
174156
else:

‎_mysql.c

Copy file name to clipboardExpand all lines: _mysql.c
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,7 @@ typedef struct {
9595
extern PyTypeObject _mysql_ResultObject_Type;
9696

9797
static int _mysql_server_init_done = 0;
98-
#if MYSQL_VERSION_ID >= 40000
9998
#define check_server_init(x) if (!_mysql_server_init_done) { if (mysql_server_init(0, NULL, NULL)) { _mysql_Exception(NULL); return x; } else { _mysql_server_init_done = 1;} }
100-
#else
101-
#define check_server_init(x) if (!_mysql_server_init_done) _mysql_server_init_done = 1
102-
#endif
10399

104100
#if MYSQL_VERSION_ID >= 50500
105101
#define HAVE_OPENSSL 1
@@ -2947,13 +2943,11 @@ _mysql_NewException(
29472943
char *name)
29482944
{
29492945
PyObject *e;
2950-
29512946
if (!(e = PyDict_GetItemString(edict, name)))
29522947
return NULL;
2953-
if (PyDict_SetItemString(dict, name, e)) return NULL;
2954-
#ifdef PYPY_VERSION
2948+
if (PyDict_SetItemString(dict, name, e))
2949+
return NULL;
29552950
Py_INCREF(e);
2956-
#endif
29572951
return e;
29582952
}
29592953

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.