MCPcopy Create free account
hub / github.com/CL-lau/SQL-GPT / add_db

Method add_db

sql/SQLOperator.py:67–79  ·  view source on GitHub ↗
(self, dbAddress: Optional[str], dbPort: Optional[str], userName: Optional[str], password: Optional[str], dbName: Optional[str], dbID: Optional[str])

Source from the content-addressed store, hash-verified

65 return -1, -1
66
67 def add_db(self, dbAddress: Optional[str], dbPort: Optional[str], userName: Optional[str], password: Optional[str], dbName: Optional[str], dbID: Optional[str]) -> str:
68 db = pymysql.connect(host=dbAddress, port=int(dbPort), user=userName, password=password, database=dbName)
69
70 for key, value in self.dbMap.items():
71 if value.host == dbAddress and value.port == int(dbPort) and value.user == userName and value.password == password and value.database == dbName:
72 return key
73
74 if dbID is None:
75 dbID = self.generated_id()
76 self.dbMap[dbID] = db
77 else:
78 self.dbMap[dbID] = db
79 return dbID
80
81 def generated_id(self) -> str:
82 characters = string.ascii_letters + string.digits

Callers

nothing calls this directly

Calls 1

generated_idMethod · 0.95

Tested by

no test coverage detected