GeoEco.Datasets.Database.ImportTable
- Database.ImportTable(destTableName, sourceTable, fields=None, where=None, orderBy=None, rowCount=None, reportProgress=True, rowDescriptionSingular=None, rowDescriptionPlural=None, copiedOIDFieldName=None, allowSafeCoercions=True, **options)
Creates a new table from an existing
Table, copying some or all of its fields and rows.- Raises:
RuntimeError – The table already exists, or some other problem occurred when creating it, adding fields, or copying rows.
Requires: Python bindings for the Geospatial Data Abstraction Library (GDAL).
- Parameters:
destTableName (
str) – Name of the table to create. Minimum length꞉ 1.fields (
listofstr, optional) – Names of the fields in sourceTable to copy to the new table. If omitted, all the fields in sourceTable will be copied.where (
str, optional) – SQL WHERE clause expression that specifies the subset of rows to copy. If not provided, all of the rows will be copied. If provided but the underlying storage format does not support WHERE clauses, an exception will be raised. The exact syntax of this expression depends on the underlying storage format. If the underlying data store will be accessed through ArcGIS, this article may document some of the possible syntax, but not all of it may be supported through ArcGIS’s underlying Python API. Minimum length꞉ 1.orderBy (
str, optional) –SQL ORDER BY clause that specifies the order in which the rows should be copied. If not provided, the rows will copied according to the default behavior of the underlying storage format and the programming library used to access it.
The ORDER BY clause must be a comma-separated list of fields. Each field can optionally be followed by a space and the word
ASCto indicate ascending order orDESCto indicate descending order. If neither is specified,ASCis assumed.The underlying storage format and library perform the actual evaluation of this parameter and determine the rules of sorting, such as whether string comparisons are case-sensitive or case-insensitive. At present, there is no mechanism to interrogate or manipulate these rules; you must live with the default behavior of the underlying format and library.
Minimum length꞉ 1. Must match regular expression꞉
\s*\S+(\s+([aA][sS][cC]|[dD][eE][sS][cC]))?\s*(,\s*\S+(\s+([aA][sS][cC]|[dD][eE][sS][cC]))?\s*)*.rowCount (
int, optional) –Number of rows that will be copied, if it is known ahead of time. If the number of rows is not known, omit this parameter.
This parameter is only used in progress reporting and is ignored if reportProgress is False. If this parameter is provided, the progress reports will include the number of rows remaining and an estimated time of completion. If not provided, the progress reports will only include the number of rows copied so far.
If you omit both this and the where parameter, and the underlying storage format and programming library support retrieval of row counts, then the row count will be obtained automatically when the copy is started.
Minimum value꞉ 0.
reportProgress (
bool, optional) – If True, progress messages will be logged periodically as the import proceeds.rowDescriptionSingular (
str, optional) – Word to use in progress and error messages for a single row. If omitted, an appropriate generic word will be automatically selected based on the table’s geometry type, such as “point”, “line”, “polygon”, and so on. If the table does not have geometry, “row” will be used. Minimum length꞉ 1.rowDescriptionPlural (
str, optional) – Word to use in progress and error messages for plural rows. If omitted, an appropriate generic word will be automatically selected based on table’s geometry type, such as “points”, “lines”, “polygons”, and so on. If the table does not have geometry, “rows” will be used. Minimum length꞉ 1.copiedOIDFieldName (
str, optional) –Name of a field to create in the new table that will receive a copy of the “object IDs” from sourceTable (e.g. the
OBJECTIDfield of a geodatabase orFIDfield of a shapefile). If not provided, the object IDs will not be copied.Note that, depending on the underlying storage format, the new table will likely have its own object ID field that contains the IDs of the new rows. Because the object IDs are automatically assigned by the underlying data store, they are not guaranteed to be the same as those in sourceTable. The purpose of copiedOIDFieldName is to allow you to retain a copy of object IDs as they existed in sourceTable.
Minimum length꞉ 1.
allowSafeCoercions (
bool, optional) – If True, when the underlying storage format does not support the data type of a field of sourceTable, the most compact alternative data type will be chosen, so long as it can represent all possible values allowed by the source table’s data type. If False, coercions of this kind will not be allowed and an exception will be raised.options (
dictmappingstrtoobject) – Additional options specific to the underlying storage format.
- Returns:
Tablerepresenting the new table.- Return type: