Attach Database (Production Mapping)

Уровень лицензии:BasicStandardAdvanced

Краткая информация

Attaches a .mdf file to an instance of SQL Server Express. This creates a geodatabase from the input .mdf file. Detach and attach allow you to move geodatabases between instances of SQL Server Express.

Use attach and detach to transfer geodatabases from one SQL Server Express instance to another. After the geodatabase has been detached from one instance, it can be attached to a different instance of SQL Server Express.

Использование

Синтаксис

AttachDatabase_production (server_name, mdf_file_path)
ПараметрОбъяснениеТип данных
server_name

The name of the SQL Server instance to which the .mdf file will be attached.

String
mdf_file_path

The path to the .mdf file.

File

Пример кода

AttachDatabase example (stand-alone script)

The following stand-alone script demonstrates how to use the AttachDatabase tool.

# Name: AttachDatabase_Example.py
# Description: Attaches a SQL Server Express geodatabase (.mdf file) to an instance of SQL Server
# Requires: Production Mapping extension

# Import arcpy module
import arcpy

# Check out any necessary licenses
arcpy.CheckOutExtension("Foundation")

# Local variables:
Server_Name = "YOUR_SERVER_NAME\\SQLEXPRESS"
Product_Library_mdf = "C:\\Data\\Product_Library.mdf"
Data = "C:\\Data"

# Database_Name = "Product_Library"
Database_Platform = "SQL_SERVER"

# Attach Database
Database_Name = arcpy.AttachDatabase_production(Server_Name, Product_Library_mdf)
print (Database_Name)

# Process: Create Database Connection
ProductLibrary_Workspace = arcpy.CreateDatabaseConnection_management(Data, Database_Name, Database_Platform, Server_Name, "OPERATING_SYSTEM_AUTH", "", "*****", "SAVE_USERNAME", Database_Name, "", "TRANSACTIONAL", "dbo.DEFAULT", "")

print (ProductLibrary_Workspace)
arcpy.CheckInExtension("Foundation")

Параметры среды

Информация о лицензировании

ArcGIS for Desktop Basic: Нет
ArcGIS for Desktop Standard: Требует Production Mapping
ArcGIS for Desktop Advanced: Требует Production Mapping
4/27/2014