adding all files done so far
This commit is contained in:
19
learning/singletons/db.py
Normal file
19
learning/singletons/db.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.getcwd()) # noqa E402
|
||||
this = sys.modules[__name__]
|
||||
|
||||
print(this)
|
||||
|
||||
this.db_name = None
|
||||
|
||||
print(this.db_name)
|
||||
|
||||
|
||||
def initialize_db(name):
|
||||
if (this.db_name is None):
|
||||
this.db_name = name
|
||||
# db_name = "Local Variable"
|
||||
else:
|
||||
msg = f"Database is already initialized to {name}"
|
||||
raise RuntimeError(msg.format(this.db_name))
|
||||
Reference in New Issue
Block a user