We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4050c74 commit d30d54cCopy full SHA for d30d54c
MySQLdb/connections.py
@@ -11,6 +11,7 @@
11
NotSupportedError, ProgrammingError
12
import _mysql
13
import re
14
+import os
15
16
17
if not PY2:
@@ -144,7 +145,12 @@ class object, used to create cursors (keyword only)
144
145
from MySQLdb.converters import conversions
146
from weakref import proxy
147
- kwargs2 = kwargs.copy()
148
+ # Load values from the environment if provided.
149
+ # Anything passed locally overrides the environment.
150
+ kwargs2 = {key.split("PY_MYSQL_CONNECT_", 1)[1].lower(): value
151
+ for key, value in os.environ.items
152
+ if key.startswith("PY_MYSQL_CONNECT_")}
153
+ kwargs2.update(kwargs)
154
155
if 'database' in kwargs2:
156
kwargs2['db'] = kwargs2.pop('database')
0 commit comments