Skip to content

Error populating geography.city #282

Open
@simcop2387

Description

@simcop2387

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
psycopg/psycopg2#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions