mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-10-03 15:56:17 +00:00
Added support to postgresql and Mysql with SqlAlchemy
This commit is contained in:
@@ -1803,7 +1803,10 @@ class DashboardConfig:
|
||||
"welcome_session": "true"
|
||||
},
|
||||
"Database":{
|
||||
"type": "sqlite"
|
||||
"type": "sqlite",
|
||||
"host": "",
|
||||
"username": "",
|
||||
"password": ""
|
||||
},
|
||||
"Email":{
|
||||
"server": "",
|
||||
@@ -1829,6 +1832,13 @@ class DashboardConfig:
|
||||
self.APIAccessed = False
|
||||
self.SetConfig("Server", "version", DASHBOARD_VERSION)
|
||||
|
||||
def getConnectionString(self, database) -> str or None:
|
||||
if self.GetConfig("Database", "type")[1] == "sqlite":
|
||||
return f'sqlite:///{os.path.join(CONFIGURATION_PATH, "db", f".db")}'
|
||||
elif self.GetConfig("Database", "type")[1] == "postgresql":
|
||||
return f'postgresql+psycopg2://{self.GetConfig("Database", "username")[1]}:{self.GetConfig("Database", "password")[1]}@{self.GetConfig("Database", "host")[1]}/{database}'
|
||||
return None
|
||||
|
||||
def __createAPIKeyTable(self):
|
||||
existingTable = sqlSelect("SELECT name FROM sqlite_master WHERE type='table' AND name = 'DashboardAPIKeys'").fetchall()
|
||||
if len(existingTable) == 0:
|
||||
@@ -3185,8 +3195,8 @@ def InitWireguardConfigurationsList(startup: bool = False):
|
||||
|
||||
AllPeerShareLinks: PeerShareLinks = PeerShareLinks()
|
||||
AllPeerJobs: PeerJobs = PeerJobs()
|
||||
JobLogger: PeerJobLogger = PeerJobLogger(CONFIGURATION_PATH, AllPeerJobs)
|
||||
DashboardLogger: DashboardLogger = DashboardLogger(CONFIGURATION_PATH)
|
||||
JobLogger: PeerJobLogger = PeerJobLogger(CONFIGURATION_PATH, AllPeerJobs, DashboardConfig)
|
||||
DashboardLogger: DashboardLogger = DashboardLogger(CONFIGURATION_PATH, DashboardConfig)
|
||||
_, app_ip = DashboardConfig.GetConfig("Server", "app_ip")
|
||||
_, app_port = DashboardConfig.GetConfig("Server", "app_port")
|
||||
_, WG_CONF_PATH = DashboardConfig.GetConfig("Server", "wg_conf_path")
|
||||
|
Reference in New Issue
Block a user