Skip to content

Commit 383fb2b

Browse files
committed
fix: do not import MySQLdb unless necessary
1 parent fddfcf9 commit 383fb2b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060

6161
import importlib_metadata as metadata
6262
import importlib_resources
63-
import MySQLdb
6463
from diraccfg import CFG
6564
from prompt_toolkit import prompt
6665

@@ -96,7 +95,6 @@
9695
findServices,
9796
)
9897
from DIRAC.Core.Utilities.File import mkDir, mkLink
99-
from DIRAC.Core.Utilities.MySQL import MySQL
10098
from DIRAC.Core.Utilities.PrettyPrint import printTable
10199
from DIRAC.Core.Utilities.ReturnValues import S_ERROR, S_OK
102100
from DIRAC.Core.Utilities.Subprocess import systemCall
@@ -2055,6 +2053,8 @@ def installDatabase(self, dbName):
20552053
"""
20562054
Install requested DB in MySQL server
20572055
"""
2056+
import MySQLdb
2057+
20582058
dbName = MySQLdb.escape_string(dbName.encode()).decode()
20592059
if not self.mysqlRootPwd:
20602060
rootPwdPath = cfgInstallPath("Database", "RootPwd")
@@ -2202,6 +2202,8 @@ def execMySQL(self, cmd, dbName="mysql", localhost=False):
22022202
"""
22032203
Execute MySQL Command
22042204
"""
2205+
from DIRAC.Core.Utilities.MySQL import MySQL
2206+
22052207
if not self.mysqlRootPwd:
22062208
return S_ERROR("MySQL root password is not defined")
22072209
if dbName not in self.db:

0 commit comments

Comments
 (0)