Generate with Python check other column

moody31415moody31415 Posts: 8
edited July 13, 2015 6:31AM in SQL Data Generator
I'm trying to create a Python script to generate data, and generate that data partially based off of a previous column.
Eg, I'm generating a sample set of "folders" for an area path - Area Level 1, Area Level 2, etc.
The example here: ... on+scripts for "Years of service" shows that it is possible to get data from other columns... but that doesn't work if the column name has spaces. How can I get it to work if the column name has spaces? quotes, [], (), {}, etc. don't seem to work.

what I want is "if area level 2 is null, then area level 3 and so on should also be null"



  • Hi,

    SQL Data Generator removes the spaces from the column names. For example, if my column is named name with spaces, it would be referred to as namewithspaces in the Python script. For example, my script for the name with spaces column would be something like this -
    def main(config):
        firstName = namewithspaces
        if firstName == 'Lee' :
            return 'Lee'
            return 'Not Lee'

    There's a button underneath the script named "Insert Column Name..." - this will take care of everything for you so it makes it really easy.

    I hope this helps.
    Software Engineer
    Redgate Software
Sign In or Register to comment.