以下是我代码的相关部分:try:
if self.pass_entry.get():
self.connection = pymysql.connect(
host=self.host_entry.get(),
user=self.user_entry.get(),
password=self.pass_entry.get(),
db=self.db_entry.get(),
charset="utf8mb4",
cursorclass=pymysql.cursors.DictCursor
)
else:
self.connection = pymysql.connect(
host=self.host_entry.get(),
user=self.user_entry.get(),
db=self.db_entry.get(),
charset="utf8mb4",
cursorclass=pymysql.cursors.DictCursor
)
except Exception as e:
self.console.insert(tk.END, "Error: {err}\n".format(err=str(e)))
错误如下:
^{pr2}$
这里“root”上没有密码,PyMySQL假设它有一个密码。如何在不使用密码的情况下连接?(当password字段/string为空时,我尝试省略password选项,但PyMySQL没有考虑它)。在