Don't crash when imported but DB url is not present

This commit is contained in:
Scoder12
2020-07-27 14:46:04 -07:00
parent f4896d432b
commit 777c9a0c70
+9 -1
View File
@@ -276,4 +276,12 @@ class ReplitDb(dict):
return f"<ReplitDb(db_url={self.db_url!r})>"
db = ReplitDb(os.environ["REPLIT_DB_URL"])
db_url = os.environ.get("REPLIT_DB_URL")
if db_url:
db = ReplitDb(db_url)
else:
print(
"Warning: REPLIT_DB_URL does not exist, are we running on repl.it? Database will not function.",
file=stderr,
)
db = None