January 2019
Beginner
318 pages
8h 23m
English
First, we will see an example of getting the database version. For that, we will create a get_database_version.py script and write the following content in it:
import MySQLdb as mdbimport syscon_obj = mdb.connect('localhost', 'test_user', 'test123', 'test')cur_obj = con_obj.cursor()cur_obj.execute("SELECT VERSION()")version = cur_obj.fetchone()print ("Database version: %s " % version)con_obj.close()
Run the script and you will get the following output:
student@ubuntu:~/work/mysql_testing$ python3 get_database_version.pyOutput:Database version: 5.7.24-0ubuntu0.18.04.1
In the preceding example, we got the database ...
Read now
Unlock full access