Blog Post

Getting the Random Module in SQL Data Generator

,

This is a series on SQL Data Generator, covering some interesting scenarios I’ve run into. If you’ve never tried it, SQL Data Generator is a part of the SQL Toolbelt. Give it a try today with an evaluation today.

I have SQL Data Generator, and use it regularly to build quick  test data in non-trivial scenarios. One of the things I ran into recently was a minor bug, but one that’s been logged. Hopefully you won’t need this, but in case you do.

I was trying to use a Python script and return a random value from a list. My code was:

return random.choice(mylist)

This gave me an error.

2017-10-05 11_02_09-SQL Data Generator - New project _

No biggie, I’ll add “import random” to the top of the script. That didn’t help. Apparently the distro with SQL Data Generator is missing the random module for some reason.

Fortunately, I have Python 2.7 on my system. I clicked “Tools” and “Application Options” in SQL Data Generator.

2017-10-05 11_00_47-SQL Data Generator - New project _

This gave me a dialog. On the General tab, there’s a “Python” section. I added the path to my Python lib folder in here.

2017-10-05 11_01_00-Application Options

That worked fine. I didn’t need to import random; it was available. My script now worked.

Filed under: Blog Tagged: Data Generator, Redgate, syndicated

Read 3,669 times
(22 in last 30 days)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating