PostgresOSM¶
-
class
pydriosm.ios.PostgresOSM(host='localhost', port=5432, username='postgres', password=None, database_name='postgres', data_source='Geofabrik', data_dir=None, max_tmpfile_size=5000, **kwargs)¶ I/O and storage of OSM data extracts with PostgreSQL.
- Parameters
host (str or None) – host address, defaults to
'localhost'(or'127.0.0.1')port (int or None) – port, defaults to
5432username (str or None) – database username, defaults to
'postgres'password (str or int or None) – database password, defaults to
Nonedatabase_name (str) – database name, defaults to
'postgres'data_source (str) – name of data sources; options include
'Geofabrik'(default) and'BBBike'kwargs – optional parameters of the class pyhelpers.sql.PostgreSQL
- Variables
ValidDataSources (tuple) – valid names of data sources
Downloaders (dict) – instances of the classes for downloading data, including
GeofabrikDownloaderandBBBikeDownloaderReaders (dict) – instances of the classes for downloading data, including
GeofabrikReaderandBBBikeReaderDataSource (str) – name of data sources, options include
'Geofabrik'and'BBBike'
Example:
>>> from pydriosm.ios import PostgresOSM >>> database_name = 'osmdb_test' >>> osmdb_test = PostgresOSM(database_name=database_name) Password (postgres@localhost:5432): *** Connecting postgres:***@localhost:5432/osmdb_test ... Successfully. >>> print(osmdb_test.DataSource) Geofabrik >>> type(osmdb_test.Downloader) pydriosm.downloader.GeofabrikDownloader >>> type(osmdb_test.Reader) pydriosm.reader.GeofabrikReader >>> # Change the data source: >>> osmdb_test.DataSource = 'BBBike' >>> type(osmdb_test.Downloader) pydriosm.downloader.BBBikeDownloader >>> type(osmdb_test.Reader) pydriosm.reader.BBBikeReader
Methods
alter_table_schema(table_name, schema_name, …)Move a table from one schema to another within the database being connected.
connect_database([database_name, verbose])Establish a connection to a database of the PostgreSQL server being connected.
create_database(database_name[, verbose])An alternative to sqlalchemy_utils.create_database.
create_schema(schema_name[, verbose])Create a new schema in the database being connected.
create_table(table_name, column_specs[, …])Create a new table for the database being connected.
database_exists([database_name])Check if a database exists in the PostgreSQL server being connected.
disconnect_database([database_name, verbose])Kill the connection to a database in the PostgreSQL server being connected.
Kill connections to all other databases of the PostgreSQL server being connected.
drop_database([database_name, …])Drop a database from the PostgreSQL server being connected.
drop_schema(schema_names[, …])Drop a schema in the database being connected.
drop_subregion_table(subregion_table_names)Delete all or specific schemas/layers of subregion data from the database being connected.
drop_table(table_name[, schema_name, …])Remove a table from the database being connected.
fetch_osm_data(subregion_name[, …])Fetch OSM data (of one or multiple layers) of a geographic region.
get_column_info(table_name[, schema_name, …])Get information about columns of a table.
get_database_size([database_name])Get the size of a database in the PostgreSQL server being connected.
get_subregion_table_column_info(…[, …])Get information about columns of a specific schema and table data of a geographic region.
get_table_name_for_subregion(subregion_name)Get the default table name for a specific geographic region.
import_data(data, table_name[, schema_name, …])Import tabular data into the database being connected.
import_osm_data(osm_data, table_name[, …])Import OSM data into a database.
import_osm_layer(osm_layer_data, table_name, …)Import one layer of OSM data into a table.
import_subregion_osm_pbf(subregion_names[, …])Import data of geographic region(s) that do not have (sub-)subregions into a database.
list_table_names([schema_name, verbose])List the names of all tables in a schema.
psql_insert_copy(sql_table, sql_db_engine, …)A callable using PostgreSQL COPY clause for executing inserting data.
read_sql_query(sql_query[, method, …])Read table data by SQL query (recommended for large table).
read_table(table_name[, schema_name, …])Read data from a table of the database being connected.
schema_exists(schema_name)Check if a schema exists in the PostgreSQL server being connected.
subregion_table_exists(subregion_name, …)Check if a table (for a geographic region) exists.
table_exists(table_name[, schema_name])Check if a table exists in the database being connected.
Attributes
An instance of either
GeofabrikDownloaderorBBBikeDownloader, depending on the specifieddata_sourcefor creating an instance ofPostgresOSMinstance.Name of the current
PostgresOSM.Downloader.An instance of either
GeofabrikReaderorBBBikeReader, depending on the specifieddata_sourcefor creating an instance ofPostgresOSM.Homepage URL of data resource for current
PostgresOSM.Downloader.