mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-08 19:50:31 -07:00
add utils function to get server type (MySQL vs MariaDB)
This commit is contained in:
parent
a7ea11353c
commit
3da5b34006
2 changed files with 8 additions and 0 deletions
|
@ -194,6 +194,13 @@ def mysql_common_argument_spec():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_server_type(cursor):
|
||||||
|
""" Return MySQL or MariaDB after quering the server
|
||||||
|
using SELECT VERSION()"""
|
||||||
|
srv_ver = get_server_version(cursor)
|
||||||
|
return 'mariadb' if 'mariadb' in srv_ver.lower() else "mysql"
|
||||||
|
|
||||||
|
|
||||||
def get_server_version(cursor):
|
def get_server_version(cursor):
|
||||||
"""Returns a string representation of the server version."""
|
"""Returns a string representation of the server version."""
|
||||||
cursor.execute("SELECT VERSION() AS version")
|
cursor.execute("SELECT VERSION() AS version")
|
||||||
|
|
|
@ -16,6 +16,7 @@ from ansible.module_utils.six import iteritems
|
||||||
|
|
||||||
from ansible_collections.community.mysql.plugins.module_utils.mysql import (
|
from ansible_collections.community.mysql.plugins.module_utils.mysql import (
|
||||||
mysql_driver,
|
mysql_driver,
|
||||||
|
get_server_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue