PostgresOSM.drop_subregion_table

PostgresOSM.drop_subregion_table(subregion_table_names, schema_names=None, table_named_as_subregion=False, schema_named_as_layer=False, confirmation_required=True, verbose=False)[source]

Delete all or specific schemas/layers of subregion data from the database being connected.

Parameters
  • subregion_table_names (str) – name of table for a subregion (or name of a subregion)

  • schema_names (list or None) – names of schemas for each layer of the PBF data, if None (default), use the default layer names as schema names

  • table_named_as_subregion (bool) – whether to use subregion name to be a table name, defaults to False

  • schema_named_as_layer (bool) – whether a schema is named as a layer name, defaults to False

  • confirmation_required (bool) – whether to prompt a message for confirmation to proceed, defaults to True

  • verbose (bool or int) – whether to print relevant information in console as the function runs, defaults to False

Examples:

>>> from pydriosm.ios import PostgresOSM

>>> osmdb_test = PostgresOSM(database_name='osmdb_test')
Password (postgres@localhost:5432): ***
Connecting postgres:***@localhost:5432/osmdb_test ... Successfully.

>>> # With all the examples for the methods:
>>> # `.import_osm_data()` and `.import_subregion_osm_pbf()`,
>>> # delete all data of Rutland and Leeds

>>> subregion_tbl_names = ['Rutland', 'Leeds']

>>> osmdb_test.drop_subregion_table(subregion_tbl_names, verbose=True)
Confirmed to drop the following tables:
    "Leeds" and
    "Rutland"
  from the following schemas:
    "multipolygons",
    "water",
    "multilinestrings",
    "points",
    "buildings",
    "natural",
    "roads",
    "other_relations",
    "pois",
    "traffic",
    "transport",
    "pofw",
    "landuse",
    "railways",
    "waterways",
    "lines" and
    "places"
  at postgres:***@localhost:5432/osmdb_test
? [No]|Yes: yes
Dropping tables ...
    "multipolygons"."Rutland" ... Done.
    "water"."Rutland" ... Done.
    "multilinestrings"."Rutland" ... Done.
    "points"."Leeds" ... Done.
    "points"."Rutland" ... Done.
    "buildings"."Leeds" ... Done.
    "buildings"."Rutland" ... Done.
    "natural"."Leeds" ... Done.
    "natural"."Rutland" ... Done.
    "roads"."Leeds" ... Done.
    "roads"."Rutland" ... Done.
    "other_relations"."Rutland" ... Done.
    "pois"."Rutland" ... Done.
    "traffic"."Rutland" ... Done.
    "transport"."Rutland" ... Done.
    "pofw"."Rutland" ... Done.
    "landuse"."Leeds" ... Done.
    "landuse"."Rutland" ... Done.
    "railways"."Leeds" ... Done.
    "railways"."Rutland" ... Done.
    "waterways"."Leeds" ... Done.
    "waterways"."Rutland" ... Done.
    "lines"."Rutland" ... Done.
    "places"."Leeds" ... Done.
    "places"."Rutland" ... Done.

>>> # Delete 'points' and 'other_relations' of Waterloo and Victoria

>>> subregion_tbl_names = ['Waterloo', 'Victoria']
>>> lyr_schema_names = ['points', 'other_relations']

>>> osmdb_test.drop_subregion_table(subregion_tbl_names, lyr_schema_names,
...                                 verbose=True)
Confirmed to drop the following tables:
    "Waterloo" and
    "Victoria"
  from the following schemas:
    "points" and
    "other_relations"
  at postgres:***@localhost:5432/osmdb_test
? [No]|Yes: yes
Dropping tables ...
    "points"."Victoria" ... Done.
    "points"."Waterloo" ... Done.
    "other_relations"."Victoria" ... Done.
    "other_relations"."Waterloo" ... Done.

>>> # Delete the database 'osmdb_test'
>>> osmdb_test.PostgreSQL.drop_database(verbose=True)
Confirmed to drop the database "osmdb_test" from postgres:***@localhost:5432
? [No]|Yes: yes
Dropping "osmdb_test" ... Done.