import sys import mysql.connector if len(sys.argv) < 2: print("Usage: python movie2.py ") exit() aname = sys.argv[1] cnx = mysql.connector.connect(user='alice', password='tiger', host='sql.cs.oberlin.edu', database='imdb', charset='utf8', auth_plugin='mysql_native_password') cursor = cnx.cursor() query = ("select title,year,role from imdb.productions natural join imdb.principals natural join imdb.persons where name=%s and type = 'movie' and category != 'self' order by year") cursor.execute(query, (aname,)) for (title,year,role) in cursor: movieid = title+" ("+str(year)+")" print(u"{:40} {}".format(movieid,role)) cursor.close() cnx.close()