gpf_entrepot_toolbelt.utils.database_inspection module¶
Database inspection helpers.
- class gpf_entrepot_toolbelt.utils.database_inspection.PgDatabaseInspector(db: PgDatabase)¶
Bases :
object
- __init__(db: PgDatabase) None ¶
Database inspector.
Use postgis special tables to get database information needed for output stored_data definition.
- Paramètres:
db (PgDatabase) – database description
- fetch_all(sql: str, entire_row: bool = False) Any | list[Any] ¶
Fetch all records of SQL request.
- Paramètres:
sql (str) – query string
entire_row (bool, optional) – True to get all rows values, False get only first column (default False)
- Renvoie:
record values
- Type renvoyé:
Union[Any,List[Any]]
- get_column_and_type_names(schema_name: str, table_name: str) dict ¶
Returns the list of columns names and there types.
- Paramètres:
schema_name (str) – schema name
table_name (str) – table name
- Renvoie:
{ column name: type }
- Type renvoyé:
dict
- get_column_names(schema_name: str, table_name: str) list[str] ¶
Returns the list of columns names.
- Paramètres:
schema_name (str) – schema name
table_name (str) – table name
- Renvoie:
List[str] column names
- get_geometry_columns_name(schema_name: str, table_name: str) list[str] ¶
Returns the columns name of a table
- Paramètres:
schema_name (str) – schema name
table_name (str) – table name
- Renvoie:
columns name from schema_name.table_name
- Type renvoyé:
List[str]
- get_gis_table_from_schema(schema_name: str) list[str] ¶
Get list of geometric tables for a schema.
- Paramètres:
schema_name (str) – schema name
- Renvoie:
list of gis table
- Type renvoyé:
Lisr[str]
- get_number_table(schema_name: str = '') int ¶
Get number of table in schema.
- Paramètres:
schema_name (str, optional) – schema name. Defaults to « « .
- Renvoie:
number of table in schema
- Type renvoyé:
int
- get_primary_keys_column(schema_name: str, table_name: str) list[str] ¶
Returns the column of primary keys.
- Paramètres:
schema_name (str) – schema name
table_name (str) – table name
- Renvoie:
primary key columns
- Type renvoyé:
List[str]
- get_schema_extent(schema_name: str, schema_srid: int, output_srid: int = 4326, precision: int = 500) GpfExtent ¶
Returns the schema extent
- Paramètres:
schema_name (str) – schema name
schema_srid (int) – SRID of data schema
output_srid (int, optional) – SRID of the calculated extent. Defaults to 4326.
precision (int, optional) – Number of squares describing schema dataset. Defaults to 500.
- Renvoie:
extent of the whole dataset stored in the schema
- Type renvoyé:
- get_schema_srid(schema_name: str) list[str] ¶
- get_schema_srs(schema_name: str) list[str] ¶
Returns the srs of all tables in schema_name.
- Paramètres:
schema_name (str) – schema name
- Renvoie:
srs list
- Type renvoyé:
List[str]
- get_size_schema(schema_name: str | None = None) int ¶
Get schema size.
- Paramètres:
schema_name (str, optional) – schema name. Defaults to None.
- Renvoie:
schema(s) size
- Type renvoyé:
int
- get_table_names_from_schema(schema_name: str, include_views: bool = False) list[str] ¶
Get tables name from schema.
- Paramètres:
schema_name (str) – schema name
include_views (bool) – to get tables add views
- Renvoie:
list of table name for schema
- Type renvoyé:
List[str]
- get_table_type(schema_name: str, table_name: str) list[str] ¶
Returns the type of the table (TABLE, VIEW,…).
- Paramètres:
schema_name (str) – schema name
table_name (str) – table name
- Renvoie:
List[str] table type
- update_stored_data(stored_data: GpfStoredData, process_extent: bool = True, default_srs: str = 'EPSG:4326') GpfStoredData ¶
Update stored data to use inspection to define extra parameters
- Paramètres:
stored_data (GpfStoredData) – input stored data
process_extent (bool) – have we to process extent ? Default to True.
default_srs (int) – Default SRS to use if the generated stored_data has none
- Returns
GpfStoredData: updated stored data