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:
- You want to customize your geodatabase.
The default geodatabases (egdb and geodata) cannot be renamed, nor can they be moved to a different tablespace. If you want a geodatabase with a different name or stored in a different tablespace, you must create another geodatabase.
- You want to group your data by geodatabase.
For example, if you have multiple departments that maintain their own discrete data, you might create separate geodatabases for each group.
- Make an SSH connection to your ArcGIS for Server site.
- 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")
- Alter the values in brackets (<>) to match the information for your site and save the file with a .py extension.
- Open a command shell and set environment variables to point to the script.
- 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).
Tip:
Check the PostgreSQL log file at data/pg_log for extended error messages.
- 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>")
- 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.
- Open a command shell and set environment variables to point to the script.
- 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.
- Repeat this for each login role that will be creating data in the new geodatabase.
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.