Problem with simpe expression generator

patrykkpatrykk Posts: 2
edited February 8, 2016 4:53AM in SQL Data Generator
I have an issue with SQL Data Generator. When I try to isnert function random.randint(int1,int2) in simple expression field i get error" NameError: name 'random' is not defined."
How i can solve this problem ?
I would be grateful for answer.

Comments

  • Unfortunately there is a bug that means that the random namespace doesn't work in SQL Data Generator with Python 2.7. You need to install Python 2.6 and then point SQL Data Generator to it.

    This version works - https://www.python.org/download/releases/2.6.6/

    Once you have installed it, open SQL Data Generator and from the Tools menu, choose Application Options and then you'll see a "Python libraries:" text box on the General tab. Add the path to the lib folder of your new Python install to this. For example, my text box now has this as the contents -
    .;C:Program Files (x86)Red GateSQL Data Generator 3Lib;C:Program Files (x86)Red GateSQL Data Generator 3Dlls;C:Python26lib
    

    Save the changes and this should get things working for you.

    Let me know if you need any more assistance.
    Software Engineer
    Redgate Software
  • Robert,
    Is there an ETA on the fix for the Python 2.7 bug?
  • jlieske wrote:
    Robert,
    Is there an ETA on the fix for the Python 2.7 bug?

    Unfortunately not. Although I have found a workaround. You can import the random functionality from the .net assembly's CLR itself. Here's an example -
    import clr 
    clr.AddReference("System") 
    from System import Random 
    random = Random(); 
    
    def main(config): 
        return str(random.Next(minValue, maxValue));
    

    I hope this helps.
    Software Engineer
    Redgate Software
  • PAF429PAF429 Posts: 4 New member
    Has this been resolved?
  • doreynoldsdoreynolds Posts: 3 New member
    if you take the python 26 approach noted above then bear in mind that the python library path supplied is wrong on two points: 1) it has lost the path delimeter characters \\ 2) it references version 3 of the data generator, i'm using version 4. Once you correct these then it works fine. 
Sign In or Register to comment.