add a get_server_type module_utils method to detect MySQL vs MariaDB

This commit is contained in:
Laurent Indermuehle 2023-09-14 15:41:42 +02:00
parent 1e24343375
commit 089e1c3fb1
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09
3 changed files with 16 additions and 6 deletions

View file

@ -194,6 +194,16 @@ 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)
if 'mariadb' in srv_ver.lower():
return "mariadb"
else:
return "mysql"
def get_server_version(cursor):
"""Returns a string representation of the server version."""
cursor.execute("SELECT VERSION() AS version")