Skip to content

Commit

Permalink
Merge pull request #214 from GeoNode/change_db_datastore_uri
Browse files Browse the repository at this point in the history
Change settings.GEODATABASE_URL to settings.DATABASES to get the db info
  • Loading branch information
giohappy authored Nov 27, 2023
2 parents 2d8ae57 + faeda3f commit 1fbcb73
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions importer/handlers/common/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,14 @@ def create_ogr2ogr_command(files, original_name, ovverwrite_layer, alternate):
Define the ogr2ogr command to be executed.
This is a default command that is needed to import a vector file
"""
_uri = settings.GEODATABASE_URL.replace("postgis://", "")
db_user, db_password = _uri.split("@")[0].split(":")
db_host = _uri.split("@")[1].split("/")[0]
db_port = "5432"
if ":" in db_host:
db_host, db_port = db_host.split(":")
db_name = _uri.split("@")[1].split("/")[1]

_datastore = settings.DATABASES['datastore']

disable_pg_copy = ast.literal_eval(os.getenv("DISABLE_PG_COPY_OGR2OGR", "False"))
options = f"--config PG_USE_COPY {'NO' if disable_pg_copy else 'YES'} "

options += (
"-f PostgreSQL PG:\" dbname='%s' host=%s port=%s user='%s' password='%s' \" "
% (db_name, db_host, db_port, db_user, db_password)
% (_datastore['NAME'], _datastore['HOST'], _datastore.get('PORT', 5432), _datastore['USER'], _datastore['PASSWORD'])
)
options += f'"{files.get("base_file")}"' + " "
# options += "-lco DIM=2 "
Expand Down

0 comments on commit 1fbcb73

Please sign in to comment.