- Home
- Course Detail
regularpython@gmail.com
You are now watching:
Python Conditions / of Python Decision Making Real-Time Examples
import MySQLdb from beautifultable import BeautifulTable table = BeautifulTable() table.column_headers = ["Movie Name", "Movie Language"] table.column_alignments['Movie Name'] = BeautifulTable.ALIGN_LEFT try: connection = MySQLdb.connect(user='root',password='sairam143sairam',port=3306,host='localhost') except Exception as e: print(e) else: tutorialCursor = connection.cursor() tutorialCursor.execute("SELECT movie_name,movie_language FROM bulkratings_info.tutorialstution_movies_list;") Movies = tutorialCursor.fetchall() connection.close() count = 1 for Movie in Movies: try: print(Movie) if Movie[1] == 'Telugu': table.append_row([Movie[0], Movie[1]]) if count ==10: break else: count = count + 1 except: pass print(table)