From 2db14d66c38af6bb2a330f74ce06880464aeaa6a Mon Sep 17 00:00:00 2001 From: Alessandro Cerioni <acerioni@grandlyon.com> Date: Sat, 9 Mar 2019 12:39:59 +0100 Subject: [PATCH] Setting GeoAlchemy2 dependency to version 0.5.0, as version 0.6.1 seems not to accept POINTZ, MULTILINESTRINGZ, ... geometries. Improving schema/table skipping in the field type detector. --- 5-pg-field-type-detector.py | 18 ++++++++++++++---- requirements.txt | 3 ++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/5-pg-field-type-detector.py b/5-pg-field-type-detector.py index 2195df2..10c5927 100644 --- a/5-pg-field-type-detector.py +++ b/5-pg-field-type-detector.py @@ -189,9 +189,14 @@ def generate_field_catalog( cfg, catalog=None ): #field_catalog = generate_field_catalog( cfg, pg_connection, field_catalog ) if isinstance(cfg['postgis']['databases'][dbname], dict) and 'whitelist' in cfg['postgis']['databases'][dbname].keys(): - whitelist = cfg['postgis']['databases'][dbname]['whitelist'] + schema_dot_table_whitelist = cfg['postgis']['databases'][dbname]['whitelist'] + print(schema_dot_table_whitelist) + schema_whitelist = [ x.split('.')[0] for x in schema_dot_table_whitelist ] + print(schema_whitelist) + else: - whitelist = None + schema_dot_table_whitelist = None + schema_whitelist = None #print(whitelist) @@ -207,6 +212,10 @@ def generate_field_catalog( cfg, catalog=None ): #print(schema_names) for schema_name in schema_names: + if schema_whitelist is not None: + if schema_name not in schema_whitelist: + logging.debug('Skipping schema %s' % schema_name) + continue # if schema_name != selected_schema: # continue # print(schema_name) @@ -216,8 +225,9 @@ def generate_field_catalog( cfg, catalog=None ): # continue # else: # found = True - if whitelist is not None: - if str(table) not in whitelist: + if schema_dot_table_whitelist is not None: + if str(table) not in schema_dot_table_whitelist: + logging.debug('Skipping table %s' % str(table)) continue try: diff --git a/requirements.txt b/requirements.txt index 8f9fe8c..b7eae43 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ pymongo #tqdm # Elasticsearch 6.x elasticsearch>=6.0.0,<7.0.0 -GeoAlchemy2>=0.5.0 +# N.B.: GeoAlchemy2 0.6.1 does not accept POINTZ, MULTILINESTRINGZ, ... geometries +GeoAlchemy2==0.5.0 psycopg2-binary>=2.7.0 sqlalchemy>=1.2.0,<1.3.0 -- GitLab