import pymysql
class Mysql_Operation:
def __init__(self):
try:
self.conn = pymysql.connect(
host='localhost', # IP,MySQL資料庫服務器IP地址
port=3306, # 埠,默認3306,可以不輸入
user='root', # 資料庫用戶名
password='root1', # 資料庫登錄密碼
database='ceshibeses', # 要連接的資料庫
charset='utf8' # 字符集,注意不是utf-8
)
self.cursor = self.conn.cursor()
except pymysql.err as e: # as 和except組合使用,將捕獲到的例外物件賦值給e
print('haha')
ceshi = Mysql_Operation()
大佬們 這個是我寫的連接資料庫的 目前是密碼錯的 想著測驗一下錯誤的賬號密碼 但是報錯了一個
catching classes that do not inherit from BaseException is not allowed這個情況應該怎么辦
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/268952.html
