Creating additional enterprise geodatabases in PostgreSQL

If your ArcGIS for Server site includes a PostgreSQL database cluster and enterprise geodatabases, you can create more enterprise geodatabases in PostgreSQL using a Python script that calls the Create Enterprise Geodatabase geoprocessing tool.

Some common reasons you would create additional geodatabases include the following:

Steps:
  1. Make an SSH connection to your ArcGIS for Server site.
  2. Copy the following script into a text editor:
    #Import arcpy module
    import arcpy
    
    arcpy.CreateEnterpriseGeodatabase("PostgreSQL", "<aws instance name>", "<new geodatabase name>", "DATABASE_AUTH", "postgres", "<postgres password>", "", "sde", "<sde password>", "", "/arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License10.1/sysgen/keycodes")
    
  3. Alter the values in brackets (<>) to match the information for your site and save the file with a .py extension.
  4. Open a command shell and set environment variables to point to the script.
  5. Run the script to create the geodatabase.

    If the information you provide is correct, you receive a message indicating the geodatabase was successfully created. If you receive an error message, be sure the information you provided was correct (for example, you used the correct passwords and the database name is valid).

    TipTip:

    Check the PostgreSQL log file at data/pg_log for extended error messages.

  6. You now have a new geodatabase. You must add user schemas to the database for all login roles that will create data in the geodatabase.

  7. Copy this script into a text editor to connect to the new geodatabase and create a login role with matching schema. Alternatively, you can specify an existing login role, and a schema for it will be created in the database.
    #Import arcpy module
    import arcpy
    
    CreateDatabaseConnection_management("<path to directory where connection file to be created>", "<connection file name>.sde", "POSTGRESQL", "<aws instance name>", "DATABASE_AUTH", "postgres", "<postgres password>", "<geodatabase name>", "SAVE_USERNAME")
    
    CreateDatabaseUser_management("<path to directory with connection file>/<connection file name>.sde", "DB", "<login role name>", "<login password>")
    
  8. Alter the values in brackets (<>) to match the database and login role information for your site and save the file with a .py extension.

    For example, if you want the default login role—owner—to create data in your new geodatabase, specify the owner login role in the script.

  9. Open a command shell and set environment variables to point to the script.
  10. Run the script to create a login role and schema (or a schema for an existing login role.)

    The script grants USAGE on the schema to public.

  11. Repeat this for each login role that will be creating data in the new geodatabase.

Related Topics

12/10/2013