MCPcopy Index your code
hub / github.com/saltstack/salt / version

Function version

salt/modules/mysql.py:1009–1040  ·  view source on GitHub ↗

Return the version of a MySQL server using the output from the ``SELECT VERSION()`` query. CLI Example: .. code-block:: bash salt '*' mysql.version

(**connection_args)

Source from the content-addressed store, hash-verified

1007
1008
1009def version(**connection_args):
1010 """
1011 Return the version of a MySQL server using the output from the ``SELECT
1012 VERSION()`` query.
1013
1014 CLI Example:
1015
1016 .. code-block:: bash
1017
1018 salt '*' mysql.version
1019 """
1020 if "mysql.version" in __context__:
1021 return __context__["mysql.version"]
1022
1023 dbc = _connect(**connection_args)
1024 if dbc is None:
1025 return ""
1026 cur = dbc.cursor()
1027 qry = "SELECT VERSION()"
1028 try:
1029 _execute(cur, qry)
1030 except MySQLdb.OperationalError as exc:
1031 err = "MySQL Error {}: {}".format(*exc.args)
1032 __context__["mysql.error"] = err
1033 log.error(err)
1034 return ""
1035
1036 try:
1037 __context__["mysql.version"] = salt.utils.data.decode(cur.fetchone()[0])
1038 return __context__["mysql.version"]
1039 except IndexError:
1040 return ""
1041
1042
1043def slave_lag(**connection_args):

Callers 8

_mysql_user_existsFunction · 0.70
user_existsFunction · 0.70
_mysql_user_createFunction · 0.70
user_createFunction · 0.70
_mysql_user_chpassFunction · 0.70
_mariadb_user_chpassFunction · 0.70
user_chpassFunction · 0.70
grant_existsFunction · 0.70

Calls 5

cursorMethod · 0.80
formatMethod · 0.80
_connectFunction · 0.70
_executeFunction · 0.70
errorMethod · 0.45

Tested by

no test coverage detected