import mysql.connector cnx = mysql.connector.connect(user='alice', password='tiger', host='sql.cs.oberlin.edu', database='imdb', auth_plugin='mysql_native_password') cursor = cnx.cursor(dictionary=True) query = ("select title,year from imdb.productions where title like 'Land of the %'" "and (type='movie' or type='tvMovie' or type='tvSeries') order by title,year") cursor.execute(query) for x in cursor: print("{} ({})".format(x['title'],x['year'])) cursor.close() cnx.close()