How to use check_migrate_table_exists method in autotest

Best Python code snippet using autotest_python

migrate.py

Source:migrate.py Github

copy

Full Screen

...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:...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful