def apply_migration(self, name, statements, fake=False):
import MySQLdb
connection = self.get_connection()
cursor = connection.cursor()
try:
if not fake and statements.strip():
cursor.execute(statements)
except (MySQLdb.OperationalError, MySQLdb.ProgrammingError) as e:
print('\n'.join(map(str, e.args)))
from sqlibrist.helpers import ApplyMigrationFailed
raise ApplyMigrationFailed
else:
cursor.execute('INSERT INTO sqlibrist_migrations '
'(migration) VALUES (%s);',
[name.split('/')[-1]])
评论列表
文章目录