Database version retrieving using Python

#username of MySQL: root
#Password: root
#Hostname: localhost
# Database Name in MySQL: test

import mysql.connector
x = mysql.connector.connect(user='root', password='root',host='localhost',database='test')
# prepare a cursor object using cursor() method
cursor = x.cursor()
# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")
# Fetch a single row using fetchone() method.
data = cursor.fetchone()
print ("Database version : %s " % data)
# disconnect from server
x.close()

Database connection test to MySQL

#username of MySQL: root

#Password: root

#Hostname: localhost

# Database Name in MySQL: test

import mysql.connector

x = mysql.connector.connect(user='root', password='root',host='localhost',database='test')

x.close()