Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to work with pyscopg2 version 2.9.1 #4451

Merged
merged 1 commit into from
Aug 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions scripts/get-external-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def clean_temp(self):
with self._conn.cursor() as cur:
cur.execute('''DROP TABLE IF EXISTS "{temp_schema}"."{name}"'''
.format(name=self._name, temp_schema=self._temp_schema))
self._conn.commit()
self._conn.commit()

# get the last modified date from the metadata table
def last_modified(self):
Expand All @@ -64,6 +64,7 @@ def last_modified(self):
results = cur.fetchone()
if results is not None:
return results[0]
self._conn.commit()

def grant_access(self, user):
with self._conn.cursor() as cur:
Expand Down Expand Up @@ -98,7 +99,7 @@ def index(self):
# matter since it'll never need a vacuum.
cur.execute('''ALTER TABLE "{temp_schema}"."{name}" RESET ( autovacuum_enabled );'''
.format(name=self._name, temp_schema=self._temp_schema))
self._conn.commit()
self._conn.commit()

# VACUUM can't be run in transaction, so autocommit needs to be turned on
old_autocommit = self._conn.autocommit
Expand Down Expand Up @@ -188,11 +189,12 @@ def main():

renderuser = opts.renderuser or config["settings"].get("renderuser")

with requests.Session() as s, \
psycopg2.connect(database=database,
with requests.Session() as s:
conn = None
conn = psycopg2.connect(database=database,
host=host, port=port,
user=user,
password=password) as conn:
password=password)

s.headers.update({'User-Agent': 'get-external-data.py/osm-carto'})

Expand Down Expand Up @@ -288,6 +290,8 @@ def main():
else:
logging.info(
"Table {} did not require updating".format(name))
if conn:
conn.close()


if __name__ == '__main__':
Expand Down