diff --git a/README.md b/README.md index 3171146..934f3c9 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ app.config["MYSQL_PASSWORD"] = "password" app.config["MYSQL_DB"] = "database" # Extra configs, optional: app.config["MYSQL_CURSORCLASS"] = "DictCursor" -app.config["MYSQL_EXTRA_KWARGS"] = {"ssl": {"ca": "/path/to/ca-file"}} +app.config["MYSQL_CUSTOM_OPTIONS"] = {"ssl": {"ca": "/path/to/ca-file"}} # https://mysqlclient.readthedocs.io/user_guide.html#functions-and-attributes mysql = MySQL(app) diff --git a/docs/index.rst b/docs/index.rst index c144718..014e817 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -39,7 +39,7 @@ Next, add a :class:`~flask_mysqldb.MySQL` instance to your code: app.config["MYSQL_DB"] = "database" # Extra configs, optional: app.config["MYSQL_CURSORCLASS"] = "DictCursor" - app.config["MYSQL_EXTRA_KWARGS"] = {"ssl": {"ca": "/path/to/ca-file"}} + app.config["MYSQL_CUSTOM_OPTIONS"] = {"ssl": {"ca": "/path/to/ca-file"}} # https://mysqlclient.readthedocs.io/user_guide.html#functions-and-attributes mysql = MySQL(app) @@ -77,7 +77,7 @@ directives: ``MYSQL_SQL_MODE`` If present, the session SQL mode will be set to the given string. ``MYSQL_CURSORCLASS`` If present, the cursor class will be set to the given string. ``MYSQL_AUTOCOMMIT`` If enabled, will use the autocommit feature of MySQL. Default: False -``MYSQL_EXTRA_KWARGS`` Use this to pass any extra directives that are not defined here. Default: None +``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`` ============================ =================================================== @@ -99,7 +99,7 @@ Changes: - 1.0.0: February 13, 2022 - Added option for autocommit. Thanks to `@shaunpud `_ on GitHub. - - Added option to pass any extra configuration to mysqlclient. + - Added option to pass any extra configuration to mysqlclient with MYSQL_CUSTOM_OPTIONS. - 0.2.0: September 5, 2015 diff --git a/flask_mysqldb/__init__.py b/flask_mysqldb/__init__.py index 9c9666f..ee11dee 100644 --- a/flask_mysqldb/__init__.py +++ b/flask_mysqldb/__init__.py @@ -32,7 +32,7 @@ def init_app(self, app): app.config.setdefault("MYSQL_SQL_MODE", None) app.config.setdefault("MYSQL_CURSORCLASS", None) app.config.setdefault("MYSQL_AUTOCOMMIT", False) - app.config.setdefault("MYSQL_EXTRA_KWARGS", None) + app.config.setdefault("MYSQL_CUSTOM_OPTIONS", None) if hasattr(app, "teardown_appcontext"): app.teardown_appcontext(self.teardown) @@ -82,8 +82,8 @@ def connect(self): if current_app.config["MYSQL_AUTOCOMMIT"]: kwargs["autocommit"] = current_app.config["MYSQL_AUTOCOMMIT"] - if current_app.config["MYSQL_EXTRA_KWARGS"]: - kwargs.update(current_app.config["MYSQL_EXTRA_KWARGS"]) + if current_app.config["MYSQL_CUSTOM_OPTIONS"]: + kwargs.update(current_app.config["MYSQL_CUSTOM_OPTIONS"]) return MySQLdb.connect(**kwargs)