selene-backend icon indicating copy to clipboard operation
selene-backend copied to clipboard

Error populating geography.city

Open simcop2387 opened this issue 2 years ago • 1 comments

Describe the bug A clear and concise description of what the bug is.

Bootstrap script fails during the populating of geography.city due to security changes from psycopg2 https://github.com/psycopg/psycopg2/issues/1294

A quick work around is to change that population to set the search path and make the function read like the following:

...
    with open("city.dump") as dump_file:
        cursor = db.db.cursor()
        cursor.execute("SET search_path TO geography")
        cursor.copy_from(
            dump_file,
            "city",
            columns=(
                "region_id",
                "timezone_id",
                "name",
                "latitude",
                "longitude",
                "population",
            ),
        )
    remove("city.dump")

To Reproduce Steps to reproduce the behavior: Run the bootstrap script

Expected behavior You do not get an error about a missing table because of the schema name

Log files

Populating geography.city table
Traceback (most recent call last):
  File "/opt/selene/selene-backend/db/scripts/bootstrap_mycroft_db.py", line 386, in <module>
    _populate_db()
  File "/opt/selene/selene-backend/db/scripts/bootstrap_mycroft_db.py", line 378, in _populate_db
    _populate_city_table(mycroft_db)
  File "/opt/selene/selene-backend/db/scripts/bootstrap_mycroft_db.py", line 351, in _populate_city_table
    cursor.copy_from(
psycopg2.errors.UndefinedTable: relation "geography.city" does not exist

simcop2387 avatar Feb 28 '22 15:02 simcop2387

Thanks for reporting this, @simcop2387. This has been addressed in PR #308. It will be included in the upcoming release.

chrisveilleux avatar Aug 02 '22 19:08 chrisveilleux