I working on a python script to copy domains from one geodatabase to another (to rebuild replicas/staging environments). I cannot figure out why I get the following error when it the script hits arcpy.da.NumPyArrayToTable(array, table)

Runtime error Traceback (most recent call last): File "", line 70, in File "", line 65, in migrateDomains RuntimeError: An invalid SQL statement was used. [SELECT * FROM table]

Below is my code

inputDomains = arcpy.da.ListDomains(inputDB)                               

tupLst = []

for domain in inputDomains:
    if domain.name == 'gFittingType':
        print('Domain name: {0}'.format(domain.name))
        if domain.domainType == 'CodedValue':                              
            codeValues = domain.codedValues
            for val, desc in codeValues.items():

        array = np.array(tupLst, dtype=[('code','S50'),('value','S50')])
        table = r'u:\scratch_workspace\scratch.gdb\table'
        arcpy.da.NumPyArrayToTable(array, table)

Additional info (ArcGIS 10.3)

2 Answers 2


I suggest using a GP tool Domain To Table passing in a specific domain gFittingType. You can use an in-memory table to avoid writing to the disk.

temp_table = r"in_memory\data"

Using numpy doesn't make sense when there is already a built-in GP tool created specifically for this.

However, to make my answer complete, the code you've provided doesn't throw any error in my 10.3 environment. This error could be data specific. So unless you are willing to provide more details, it will be hard to troubleshoot.

Some ideas:

  1. Try to run your code with a very simple dummy domain [(0, 'Test1'), (1, 'Test2')] to see if it would work.
  2. Look into your codes and values and whether using S50 makes sense.
  3. Make sure you have permissions to write to the output table. Try testing using a scratch geodatabase: os.path.join(arcpy.env.scratchGDB, 'tableCodes')

Env details:

  • I ended up going the GPTools route - The idea was to loop through each domain in a production database, and migrate it to an empty database for development testing. We want to automate this because there are ~ 75 domains in our database and manually migrating those has been problematic at best. I will have to do some debugging (mostly out of curiosity/learning desire) to figure out what the issue is with using numpy.array if it worked in your environment. The domains are almost all string data types with matchign coded values/descriptions. Aug 12, 2017 at 14:03

Ultimately I bypassed the error with GPTools:

arcpy.env.orverWriteOutputs = True

inputDomains = arcpy.da.ListDomains(inputDB)
scratch = r'u:\scratch_workspace\table.dbf'

for domain in inputDomains:
    print('Domain name: {0}'.format(domain.name))
    print('     {0}'.format(domain.description))


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.