Automate Enterprise Database Creation + Create Enterprise DB Connection + Create User (Utility Network related)

811
0
08-24-2021 10:03 PM
RodrigoReisDNC
New Contributor

Hi!

I'm using ArcgisPro 2.6.3 and UN Tools 2.6.2 

I'm trying to Automate the process of creating Enterprise GeoDatabases, Creating a DB user, Staging Utility Network and applying asset package.

Currently I've been able to create a python script that works for the first step (Automate the Enterprise GDB creation) but am unable to do the next step, which is to make the script connect to the Enterprise GDB created in the first step and create a Database user in this Enterprise GDB 

My googling has lead me to try and use the Create Database Connection String geoprocessing and Create Database Connection (links bellow) 

https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/create-database-connection-s...

https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/create-database-connection.h...

 

But I keep getting a 000837 Error The workspace is not the correct workspace type. 

The code I wrote is based on the example they put in the Create Database Connection string page (first code snippet bellow, second is my own code), as far as I understand they run the CreateDatabasseConnectionString and assign it to a variable and then put the variable into the first parameter of the CreateDatabaseUser function. 

 

 

 

import arcpy
data_conn_str = arcpy.CreateDatabaseConnectionString_management("SQL_SERVER",
                                          "utah",
                                          "DATABASE_AUTH",
                                          "gdb",
                                          "gdb", 
                                          "",
                                          "gdb.roads")
arcpy.Buffer_analysis(data_conn_str, r"c:\temp\Buffers.shp", "10 Miles")

 

 

 

 

 

 

import os, arcpy

gdbuser = arcpy.GetParameterAsText(0)
connectionfile = arcpy.GetParameterAsText(1) 

db_string = arcpy.management.CreateDatabaseConnectionString("SQL_SERVER", "*****", "DATABASE_AUTH", "sa", "*****", "Script_Test_Database", '', '', '', '', "BRANCH", "sde.DEFAULT", None)

arcpy.management.CreateDatabaseUser(db_string, "DATABASE_USER", gdbuser, "*****", '', '')

 

 

 

 

 

0 Kudos
0 Replies