Best Python code snippet using fMBT_python
messages.py
Source:messages.py  
...9    def success(self):10        msg = QMessageBox()11        msg.setWindowTitle("Success!")12        msg.setText("Account created!")13        x = msg.exec_()14    def show_signup(self):15        msg = QMessageBox()16        msg.setWindowTitle("Error!")17        msg.setText("Email already exists!")18        x = msg.exec_()19    def show_bookNotFound(self):20        msg = QMessageBox()21        msg.setWindowTitle("Error!")22        msg.setText("Book not found, Not in the database!")23        self.label_8.setText("Book not in the Database")24        x = msg.exec_()25    def show_checkSuccess(self):26        msg = QMessageBox()27        msg.setWindowTitle("Process Success!")28        msg.setText("Transactions completed!")29        x = msg.exec_()30    def show_scanUser(self):31        msg = QMessageBox()32        msg.setWindowTitle("Error!")33        msg.setText("Borrower Not found!")34        x = msg.exec_()35    def show_login_empty(self):36        msg = QMessageBox()37        msg.setWindowTitle("Error!")38        msg.setText("Enter a valid Username & Password")39        self.label_home.setText('Enter a valid Username & Password')40        self.label_Employee.setText('Enter a valid Username & Password')41        x = msg.exec_()42    def select(self):43        msg = QMessageBox()44        msg.setWindowTitle("Attention!")45        msg.setText("Please select a search criteria")46        self.label_8.setText("Please select a search criteria")47        x = msg.exec_()48    def book_entry(self):49        msg = QMessageBox()50        msg.setWindowTitle("Attention!")51        msg.setText("Please enter a valid input")52        self.label_37.setText("Please enter a valid input")53        x = msg.exec_()54    def book_Success(self):55        msg = QMessageBox()56        msg.setWindowTitle("Success!")57        msg.setText("Book Added")58        self.label_37.setText("Book Added")59        x = msg.exec_()60    def book_ID(self):61        msg = QMessageBox()62        msg.setWindowTitle("Error!")63        msg.setText("Please enter a valid ID")64        self.label_37.setText("Please enter a valid Book ID")65        x = msg.exec_()66    def sure(self):67        msg = QMessageBox()68        msg.setWindowTitle("Attention!")69        msg.setText("Are you sure you want to delete?")70        msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)71        self.label_37.setText("")72        x = msg.exec_()73    def book_removed(self):74        msg = QMessageBox()75        msg.setWindowTitle("Success!")76        msg.setText("Book Removed")77        self.label_37.setText("Book Removed")78        x = msg.exec_()79class Messages_passsword(QMainWindow):80    def __init__(self):81            QWidget.__init__(self)82            self.setupUi(self)83    def show_password_empty_home(self):84        msg = QMessageBox()85        msg.setWindowTitle("Error!")86        msg.setText("Please enter a valid Username!")87        self.label_home.setText('Enter a valid Username')88        self.label_Employee.setText('Enter a valid Username')89        x = msg.exec_()90    def show_password_empty(self):91        msg = QMessageBox()92        msg.setWindowTitle("Error!")93        msg.setText("Please enter a valid Username!")94        self.label_pass.setText('Enter a valid Username')95        x = msg.exec_()96    def code(self, mes):97        msg = QMessageBox()98        msg.setWindowTitle("Code Found!")99        msg.setText("Please enter the following code: " + mes)100        x = msg.exec_()101    def valid_reset_code(self):102        msg = QMessageBox()103        msg.setWindowTitle("Error!")104        msg.setText("Please enter a valid reset code!")105        self.label_pass.setText('Enter a valid reset code!')106        x = msg.exec_()107    def invalid_code(self):108        msg = QMessageBox()109        msg.setWindowTitle("Error!")110        msg.setText("Please enter a valid code!")111        self.label_pass.setText('Enter a valid code')112        x = msg.exec_()113    def show_invalid_password(self):114        msg = QMessageBox()115        msg.setWindowTitle("Error!")116        msg.setText("Please enter a valid Password!")117        self.label_pass.setText('Enter a valid Password')118        x = msg.exec_()119    def success(self):120        msg = QMessageBox()121        msg.setWindowTitle("Success!")122        msg.setText("Password updated!")123        x = msg.exec_()124    def resetAll(self):125        self.lineEdit_username_pass.clear()126        self.lineEdit_username_code.clear()127        self.lineEdit_pass1.clear()128        self.lineEdit_pass2.clear()129        self.label_pass.clear()130        self.label_home.clear()131        self.label_Employee.clear()132class Messages_user(QMainWindow):133    def resetAll(self):134        self.lbl_first.clear()  # check output values135        self.lbl_email.clear()136        self.lbl_fines.clear()137class Message_Librarian(QMainWindow):138    def __init__(self):139        QWidget.__init__(self)140        self.setupUi(self)141    def checkout_error(self):142        msg = QMessageBox()143        msg.setWindowTitle("Error!")144        msg.setText("Current Book Selected is not available to rent")145        x = msg.exec_()146    def checkin_error(self):147        msg = QMessageBox()148        msg.setWindowTitle("Error!")149        msg.setText("Book already checked In")150        x = msg.exec_()151    def Check_complete(self):152        msg = QMessageBox()153        msg.setWindowTitle("Success!")154        msg.setText("Check In Completed")155        x = msg.exec_()156class Messages_username(QMainWindow):157    def __init__(self):158            QWidget.__init__(self)159            self.setupUi(self)160    def show_username_empty(self):161        msg = QMessageBox()162        msg.setWindowTitle("Error!")163        msg.setText("Please enter a valid Username!")164        self.label_35.setText('Enter a valid Username')165        x = msg.exec_()166    def valid_reset_code(self):167        msg = QMessageBox()168        msg.setWindowTitle("Error!")169        msg.setText("Please enter a valid reset code!")170        self.label_35.setText('Enter a valid reset code!')171        x = msg.exec_()172    def invalid_code(self):173        msg = QMessageBox()174        msg.setWindowTitle("Error!")175        msg.setText("Please enter a valid code!")176        self.label_35.setText('Enter a valid code')177        x = msg.exec_()178    def success(self):179        msg = QMessageBox()180        msg.setWindowTitle("Success!")181        msg.setText("Password updated!")...connection.py
Source:connection.py  
...12                "Click Cancel to exit.",13                QMessageBox.Cancel)14        return False15    query = QSqlQuery()16    query.exec_("create table person(id int primary key, "17                "seqname varchar(20), sequence varchar(300))")18    query.exec_("insert into person values(101, 'TestSeq', 'NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNTCCCTGAGACTCTCCTGTGAAGCCTCTGGATTCACGTTTGGCGGCAATGGCATGAGCTGGGTCCGCCAGGCTCCAGGGAAGGGACTGGAGTGGGTCGCAGGTATCAGTGGTATTAGTGGGAATACATATTATTTAGGCTCCGTGAAGGGCCGGTTCACCATCTCCAGAGACAATCCGAAGAGGACGTTATATCTACAAATGAATCGTCTGAGAGTCGAGGACACGGCCATTTATTACTGTGCGAAAGATCGTTTGATAGGAACAGATGGCGTCTCTTTCTTTGACCAATGGGGCCAGGGAACCCTGGTCACCGTCTCCTCAG')")19    # query.exec_("insert into person values(102, 'Christine', 'Holand')")20    # query.exec_("insert into person values(103, 'Lars', 'Gordon')")21    # query.exec_("insert into person values(104, 'Roberto', 'Robitaille')")22    # query.exec_("insert into person values(105, 'Maria', 'Papadopoulos')")23    # query.exec_("create table offices (id int primary key,"24    #                                          "imagefile int,"25    #                                          "location varchar(20),"26    #                                          "country varchar(20),"27    #                                          "description varchar(100))");28    # query.exec_("insert into offices "29    #            "values(0, 0, 'Oslo', 'Norway',"30    #            "'Oslo is home to more than 500 000 citizens and has a "31    #            "lot to offer.It has been called \"The city with the big "32    #            "heart\" and this is a nickname we are happy to live up to.')")33    # query.exec_("insert into offices "34    #            "values(1, 1, 'Brisbane', 'Australia',"35    #            "'Brisbane is the capital of Queensland, the Sunshine State, "36    #            "where it is beautiful one day, perfect the next.  "37    #            "Brisbane is Australia''s 3rd largest city, being home "38    #            "to almost 2 million people.')")39    # query.exec_("insert into offices "40    #            "values(2, 2, 'Redwood City', 'US',"41    #            "'You find Redwood City in the heart of the Bay Area "42    #            "just north of Silicon Valley. The largest nearby city is "43    #            "San Jose which is the third largest city in California "44    #            "and the 10th largest in the US.')")45    # query.exec_("insert into offices "46    #            "values(3, 3, 'Berlin', 'Germany',"47    #            "'Berlin, the capital of Germany is dynamic, cosmopolitan "48    #            "and creative, allowing for every kind of lifestyle. "49    #            "East meets West in the metropolis at the heart of a "50    #            "changing Europe.')")51    # query.exec_("insert into offices "52    #            "values(4, 4, 'Munich', 'Germany',"53    #            "'Several technology companies are represented in Munich, "54    #            "and the city is often called the \"Bavarian Silicon Valley\". "55    #            "The exciting city is also filled with culture, "56    #            "art and music. ')")57    # query.exec_("insert into offices "58    #            "values(5, 5, 'Beijing', 'China',"59    #            "'Beijing as a capital city has more than 3000 years of "60    #            "history. Today the city counts 12 million citizens, and "61    #            "is the political, economic and cultural centre of China.')")62    #63    # query.exec_("create table images (locationid int, file varchar(20))")64    # query.exec_("insert into images values(0, 'images/oslo.png')")65    # query.exec_("insert into images values(1, 'images/brisbane.png')")66    # query.exec_("insert into images values(2, 'images/redwood.png')")67    # query.exec_("insert into images values(3, 'images/berlin.png')")68    # query.exec_("insert into images values(4, 'images/munich.png')")69    # query.exec_("insert into images values(5, 'images/beijing.png')")...concat_db_tables.py
Source:concat_db_tables.py  
...12povar_recipes = meta.tables['povar_recipes']13povar_ingredients = meta.tables['povar_ingredients']14receipts = meta.tables['receipts']15ingredients = meta.tables['ingredients']16def exec_(query):17    with conn.connect() as c:18        return c.execute(query)19def move_receipts():20    g_receipts = exec_(select([gastronom_recipes])).fetchall()21    for receipt in g_receipts:22        q = receipts.insert().values({23            'name': receipt.name,24            'preview': receipt.preview,25            'link': receipt.link,26            'description': receipt.description,27            'cooking_time': 0,28            'portions': 0,29            'difficult': 0,30            'public': 0,31            'created_at': receipt.created_at,32            'original_id': receipt.id,33            'type': 'gastronom',34        })35        exec_(q)36    p_receipts = exec_(select([parsed_recipes])).fetchall()37    for receipt in p_receipts:38        q = receipts.insert().values({39            'name': receipt.name,40            'preview': receipt.preview,41            'link': receipt.link,42            'description': receipt.description,43            'cooking_time': 0,44            'portions': 0,45            'difficult': 0,46            'public': 0,47            'created_at': receipt.created_at,48            'original_id': receipt.id,49            'type': 'ivona',50        })51        exec_(q)52    povar_receipts_all = exec_(select([povar_recipes])).fetchall()53    for receipt in povar_receipts_all:54        q = receipts.insert().values({55            'name': receipt.name,56            'preview': receipt.preview,57            'link': receipt.link,58            'description': receipt.description,59            'cooking_time': 0,60            'portions': 0,61            'difficult': 0,62            'public': 0,63            'created_at': receipt.created_at,64            'original_id': receipt.id,65            'type': 'povar',66        })67        exec_(q)68def move_ingredients():69    gastronom_ing_all = exec_(select([gastronom_ingredients])).fetchall()70    for ing in gastronom_ing_all:71        q = ingredients.insert().values({72            'name': ing.name,73            'created_at': ing.created_at,74            'receipt_id': select([receipts.c.id]).where(receipts.c.original_id == ing.recipe_id).where(receipts.c.type == 'gastronom'),75            'full_name': ing.name_full,76            'quantity': ing.quantity,77        })78        exec_(q)79    ivona_ing_all = exec_(select([parsed_ingredients])).fetchall()80    for ing in ivona_ing_all:81        q = ingredients.insert().values({82            'name': ing.name,83            'created_at': ing.created_at,84            'receipt_id': select([receipts.c.id]).where(receipts.c.original_id == ing.parsed_recipe_id).where(receipts.c.type == 'ivona'),85            'full_name': ing.name + ' ' + str(ing.quantity),86            'quantity': ing.quantity,87        })88        exec_(q)89    povar_ing_all = exec_(select([povar_ingredients])).fetchall()90    for ing in povar_ing_all:91        q = ingredients.insert().values({92            'name': ing.name,93            'created_at': ing.created_at,94            'receipt_id': select([receipts.c.id]).where(receipts.c.original_id == ing.recipe_id).where(receipts.c.type == 'povar'),95            'full_name': ing.name,96            'quantity': ing.quantity,97        })...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
