RecordSet

Resumen

RecordSet objects are a lightweight representation of a table. They are a special data element that contains not only schema but also the data. The RecordSet object is also how tables are sent and received from the server.

Debate

Nota:

If you're loading a table into a new RecordSet and modifying the RecordSet with a geoprocessing tool that modifies the input such as Calculate Field or a function such as UpdateCursor, the original table will also be modified.

Sintaxis

 RecordSet ({table})
ParámetroExplicaciónTipo de datos
table

Table to be loaded into the RecordSet object.

String

Propiedades

PropiedadExplicaciónTipo de datos
JSON
(Sólo lectura)

Returns an Esri JSON representation of the geometry as a string.

Sugerencia:

The returned string can be converted to a dictionary using the Python json.loads function.

String

Descripción general del método

MétodoExplicación
load (table_path, {where_clause})

Import from a table.

save (table_path)

Export to a table.

Métodos

load (table_path, {where_clause})
ParámetroExplicaciónTipo de datos
table_path

The table to be imported.

The input can be a catalog path to a feature class, a URL to a hosted feature layer, or a URL JSON with the syntax {"url":"<url>", "token":"<token", "referer":"<referer>"} to load data from external sources that require an access token.

String
where_clause

An SQL expression used to select a subset of records.

For more information on SQL syntax, see SQL reference for query expressions used in ArcGIS.

(El valor predeterminado es None)

String

The optional parameters are positional only; they cannot be passed by keyword.

save (table_path)
ParámetroExplicaciónTipo de datos
table_path

The output table to be created.

String

Muestra de código

RecordSet example 1

Import a server toolbox; get the RecordSet from the server tool's specified parameter.

import arcpy

# Add a custom server toolbox
arcpy.ImportToolbox("http://myserver/arcgis/services;Geocode")

# Get recordset from server tool's first parameter to use as schema
in_recordset = arcpy.GetParameterValue("GeocodeAddress", 0)
RecordSet example 2

Create a RecordSet and load a subset of a hosted table.

import arcpy

# Set data
in_dataset = "https://maps.my.org/arcgis/rest/services/Tables/MapServer/0"
query = "Country_Code: 'IT'"

# Create empty RecordSet
record_set = arcpy.RecordSet()

# Load data into RecordSet with query
record_set.load(in_dataset, query)

Temas relacionados