Module API reference

Module contents

class raster_loader.BigQueryConnection(project, credentials: Optional[Credentials] = None)

Bases: DataWarehouseConnection

check_if_table_exists(fqn: str)
check_if_table_is_empty(fqn: str)
delete_bigquery_table(fqn: str)
execute(sql)

Execute a SQL query.

execute_to_dataframe(sql)

Execute a SQL query and return the result as a pandas dataframe. :param sql: SQL query to execute. :type sql: str

Returns

Result of the query.

Return type

pandas.DataFrame

get_labels(version: str)
get_metadata(fqn)

Get metadata from a table. :param fqn: Fully qualified name of the table. :type fqn: str

Returns

Metadata from the table.

Return type

dict

quote(q)

Quote a value. :param value: Value to quote. :type value: str

Returns

Quoted value.

Return type

str

quote_name(name)

Quote a table name. :param name: Name to quote. :type name: str

Returns

Quoted name.

Return type

str

update_labels(fqn, labels)
upload_raster(file_path: str, fqn: str, bands_info: List[Tuple[int, str]] = [(1, None)], chunk_size: Optional[int] = None, overwrite: bool = False, append: bool = False, cleanup_on_failure: bool = False)

Write a raster file to a BigQuery table.

upload_records(records: Iterable, fqn)
write_metadata(metadata, append_records, fqn)

Write metadata to a table. :param metadata: Metadata to write. :type metadata: dict :param append_records: Whether to update the metadata of an existing table or insert a new record. :type append_records: bool :param fqn: Fully qualified name of the table. :type fqn: str

Returns

True if the insertion was successful, False otherwise.

Return type

bool

class raster_loader.SnowflakeConnection(username, password, account, database, schema, token, role)

Bases: DataWarehouseConnection

band_rename_function(band_name: str)
check_if_table_exists(fqn: str)
check_if_table_is_empty(fqn: str)
execute(sql)

Execute a SQL query.

execute_to_dataframe(sql)

Execute a SQL query and return the result as a pandas dataframe. :param sql: SQL query to execute. :type sql: str

Returns

Result of the query.

Return type

pandas.DataFrame

get_metadata(fqn: str)

Get metadata from a table. :param fqn: Fully qualified name of the table. :type fqn: str

Returns

Metadata from the table.

Return type

dict

upload_raster(file_path: str, fqn: str, bands_info: Optional[List[Tuple[int, str]]] = None, chunk_size: Optional[int] = None, overwrite: bool = False, append: bool = False, cleanup_on_failure: bool = False) bool

Upload a raster file to the data warehouse. :param file_path: Path to the raster file. :type file_path: str :param fqn: Fully qualified name of the table. :type fqn: str :param band: Band to upload, by default 1 :type band: int, optional :param band_name: Name of the band :type band_name: str, optional :param chunk_size: Number of blocks to upload in each chunk, by default 1000 :type chunk_size: int, optional :param overwrite: Overwrite existing data in the table if it already exists, by default False :type overwrite: bool, optional :param append: Append records into a table if it already exists, by default False :type append: bool, optional

upload_records(records: Iterable, fqn: str, overwrite: bool)
write_metadata(metadata, append_records, fqn)

Write metadata to a table. :param metadata: Metadata to write. :type metadata: dict :param append_records: Whether to update the metadata of an existing table or insert a new record. :type append_records: bool :param fqn: Fully qualified name of the table. :type fqn: str

Returns

True if the insertion was successful, False otherwise.

Return type

bool