Skip to content

Commit 8744c3e

Browse files
committed
rename config and add more info
1 parent 43e8fd3 commit 8744c3e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ app.config["MYSQL_PASSWORD"] = "password"
3535
app.config["MYSQL_DB"] = "database"
3636
# Extra configs, optional:
3737
app.config["MYSQL_CURSORCLASS"] = "DictCursor"
38-
app.config["MYSQL_EXTRA_KWARGS"] = {"ssl": {"ca": "/path/to/ca-file"}}
38+
app.config["MYSQL_CUSTOM_OPTIONS"] = {"ssl": {"ca": "/path/to/ca-file"}} # https://mysqlclient.readthedocs.io/user_guide.html#functions-and-attributes
3939

4040
mysql = MySQL(app)
4141

docs/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Next, add a :class:`~flask_mysqldb.MySQL` instance to your code:
3939
app.config["MYSQL_DB"] = "database"
4040
# Extra configs, optional:
4141
app.config["MYSQL_CURSORCLASS"] = "DictCursor"
42-
app.config["MYSQL_EXTRA_KWARGS"] = {"ssl": {"ca": "/path/to/ca-file"}}
42+
app.config["MYSQL_CUSTOM_OPTIONS"] = {"ssl": {"ca": "/path/to/ca-file"}} # https://mysqlclient.readthedocs.io/user_guide.html#functions-and-attributes
4343
4444
mysql = MySQL(app)
4545
@@ -77,7 +77,7 @@ directives:
7777
``MYSQL_SQL_MODE`` If present, the session SQL mode will be set to the given string.
7878
``MYSQL_CURSORCLASS`` If present, the cursor class will be set to the given string.
7979
``MYSQL_AUTOCOMMIT`` If enabled, will use the autocommit feature of MySQL. Default: False
80-
``MYSQL_EXTRA_KWARGS`` Use this to pass any extra directives that are not defined here. Default: None
80+
``MYSQL_CUSTOM_OPTIONS`` ``dict`` of options you want to set in this format: {option: value}. See all available option `here <# https://mysqlclient.readthedocs.io/user_guide.html#functions-and-attributes>`_. Default: ``None``
8181
============================ ===================================================
8282

8383

@@ -99,7 +99,7 @@ Changes:
9999
- 1.0.0: February 13, 2022
100100

101101
- Added option for autocommit. Thanks to `@shaunpud <https://github.com/shaunpud>`_ on GitHub.
102-
- Added option to pass any extra configuration to mysqlclient.
102+
- Added option to pass any extra configuration to mysqlclient with MYSQL_CUSTOM_OPTIONS.
103103

104104
- 0.2.0: September 5, 2015
105105

flask_mysqldb/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def init_app(self, app):
3232
app.config.setdefault("MYSQL_SQL_MODE", None)
3333
app.config.setdefault("MYSQL_CURSORCLASS", None)
3434
app.config.setdefault("MYSQL_AUTOCOMMIT", False)
35-
app.config.setdefault("MYSQL_EXTRA_KWARGS", None)
35+
app.config.setdefault("MYSQL_CUSTOM_OPTIONS", None)
3636

3737
if hasattr(app, "teardown_appcontext"):
3838
app.teardown_appcontext(self.teardown)
@@ -82,8 +82,8 @@ def connect(self):
8282
if current_app.config["MYSQL_AUTOCOMMIT"]:
8383
kwargs["autocommit"] = current_app.config["MYSQL_AUTOCOMMIT"]
8484

85-
if current_app.config["MYSQL_EXTRA_KWARGS"]:
86-
kwargs.update(current_app.config["MYSQL_EXTRA_KWARGS"])
85+
if current_app.config["MYSQL_CUSTOM_OPTIONS"]:
86+
kwargs.update(current_app.config["MYSQL_CUSTOM_OPTIONS"])
8787

8888
return MySQLdb.connect(**kwargs)
8989

0 commit comments

Comments
 (0)