Best Python code snippet using autotest_python
migrate.py
Source:migrate.py
...70 for statement in script.split(';')71 if statement.strip()]72 for statement in sql_statements:73 self.execute(statement)74 def check_migrate_table_exists(self):75 try:76 self.execute("SELECT * FROM %s" % MIGRATE_TABLE)77 return True78 except self._database.DatabaseError, exc:79 # we can't check for more specifics due to differences between DB80 # backends (we can't even check for a subclass of DatabaseError)81 return False82 def create_migrate_table(self):83 if not self.check_migrate_table_exists():84 self.execute("CREATE TABLE %s (`version` integer)" %85 MIGRATE_TABLE)86 else:87 self.execute("DELETE FROM %s" % MIGRATE_TABLE)88 self.execute("INSERT INTO %s VALUES (0)" % MIGRATE_TABLE)89 assert self._database.rowcount == 190 def set_db_version(self, version):91 assert isinstance(version, int)92 self.execute("UPDATE %s SET version=%%s" % MIGRATE_TABLE,93 version)94 assert self._database.rowcount == 195 def get_db_version(self):96 if not self.check_migrate_table_exists():97 return 098 rows = self.execute("SELECT * FROM %s" % MIGRATE_TABLE)99 if len(rows) == 0:100 return 0101 assert len(rows) == 1 and len(rows[0]) == 1102 return rows[0][0]103 def get_migrations(self, minimum_version=None, maximum_version=None):104 migrate_files = [filename for filename105 in os.listdir(self.migrations_dir)106 if re.match(r'^\d\d\d_.*\.py$', filename)]107 migrate_files.sort()108 migrations = [Migration.from_file(filename)109 for filename in migrate_files]110 if minimum_version is not None:...
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!!