- Home
- Course Detail
regularpython@gmail.com
You are now watching:
Python Operators / of Python Membership Operators RealTime Examples
import MySQLdb from beautifultable import BeautifulTable table = BeautifulTable() table.column_headers = ["movie_name", "movie_language", "movie_length", "movie_geners"] 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, movie_length, movie_geners FROM bulkratings_info.tutorialstution_movies_list;") movies = tutorialCursor.fetchall() connection.close() movie_gener = 'drama' print(movies) for movie in movies: try: #print(movie) if 'drama' not in movie[3] and 'romance' not in movie[3]: table.append_row(list(movie)) #In operator Example # if movie_gener in movie[1]: # table.append_row(list(movie)) #NOt In Operator Example # if movie_gener not in movie[1]: # table.append_row(list(movie)) except: pass print(table)