def run_migration ( connection , queries , engine ) : # Execute query with connection . cursor ( ) as cursorMig : # Parse statements queries = parse_statements ( queries , engine ) for query in queries : cursorMig . execute ( query ) connection . commit ( ) return True
mssql database automation with python
Apply a migration to the SQL server
def run_migration(connection, queries, engine):
    """ Apply a migration to the SQL server """

    # Execute query
    with connection.cursor() as cursorMig:
        # Parse statements
        queries = parse_statements(queries, engine)

        for query in queries:
            cursorMig.execute(query)
        connection.commit()

    return True