mirror of
https://github.com/kennethreitz/replit-py.git
synced 2026-06-05 23:10:18 +00:00
Don't crash when imported but DB url is not present
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user