aboutsummaryrefslogtreecommitdiffstats
path: root/manage.py
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2021-09-06 21:03:14 +0100
committerGravatar Chris Lovering <[email protected]>2021-09-06 21:07:53 +0100
commita211f99319df66ff11a75746c5f7ab40ac19122a (patch)
tree3f5da790cc43b166de4c82165ef691df3f7f0dcb /manage.py
parentInitialise metricity at runtime (diff)
Use context manager for file open
Also remove a useless print statement to reduce noise
Diffstat (limited to 'manage.py')
-rwxr-xr-xmanage.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/manage.py b/manage.py
index ad9bae5f..63602d63 100755
--- a/manage.py
+++ b/manage.py
@@ -161,7 +161,6 @@ class SiteManager:
exists = cursor.fetchone()
if exists:
# Assume metricity is already populated if it exists
- print("Metricity already exists, not creating.")
return
print("Creating metricity relations and populating with some data.")
cursor.execute("CREATE DATABASE metricity")
@@ -171,8 +170,8 @@ class SiteManager:
database="metricity",
**db_connection_kwargs
)
- with conn.cursor() as cursor:
- cursor.execute(open("postgres/init.sql").read())
+ with conn.cursor() as cursor, open("postgres/init.sql", encoding="utf-8") as f:
+ cursor.execute(f.read())
def prepare_server(self) -> None:
"""Perform preparation tasks before running the server."""