Errors now ocurring in python scripts within project that has not changed

I developed a project a year ago. Having come back to it, I get errors on some of the python scripts.
The script is very basic:
def main(config):
#
return InceptionDate.AddDays(randint(-30,-1));


InceptionDate is a date column that is populated using the randomdate functionality.
The error suggests an issue with python.
NameError: global name 'randint' is not defined.
The only change since the project was last used is the user account used to access the software. Python 2.7 is in my %PATH%
I don't understand,
Tagged:

Comments

  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Hi and thanks for your post!

    From doing a quick search, it sounds like you may need to import randint by adding the following to the top of the file:
    from random import randint
    
    This seems to work for me, can you please give it a try?

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


  • That help. Thanks. I now have another error but at least I can try and apply the same method.
Sign In or Register to comment.