|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 hejialiangya 于 2023-3-21 12:31 编辑
import sys
from PySide6.QtWidgets import QApplication,QMainWindow,QWidget,QDialog,QMessageBox
from PyQt6.QtCore import Qt
import Login
import HSJCQueryWindow
import oracledb
# 创建Login类继承HSJCQueryWindow里面全部内容
class HSJCQueryWindow(HSJCQueryWindow.Ui_MainWindow, QMainWindow):
def __init__(self):
super(HSJCQueryWindow, self).__init__()
self.setupUi(self)
class Login(Login.Ui_MainWindow, QMainWindow):
def __init__(self):
super(Login, self).__init__()
self.setupUi(self)
# 登录验证
def login_check():
username = login.UsernameLineEdit.text()
password = login.PasswordLineEdit.text()
sql = "SELECT * FROM staff_dict WHERE username = '{}' AND password = '{}'".format(username, password)
cursor.execute(sql)
result = cursor.fetchone()
if result:
hsjc_query_window.show()
else:
QMessageBox.warning(login, '警告', '用户名或密码错误!')
if __name__ == '__main__':
app = QApplication(sys.argv)
window = QMainWindow()
# 为Login类和HSJCQueryWindow类实例化对象
login = Login()
hsjc_query_window = HSJCQueryWindow()
# 显示登陆窗口
login.setupUi(window)
window.show()
# 连接oracle数据库
conn = oracledb.connect(
dsn='dbserver',
user='ZYY',
password='2023@KAV',
host='130.1.25.99',
port=1521,
service_name='orcl'
)
cursor = conn.cursor()
# 将login_check函数与登录按钮绑定
login.LoginButton.clicked.connect(login_check)
sys.exit(app.exec())
右侧数据库连接成功了,dbserver的表也都有显示。但是编译main.py时候数据库就连不上,oracledb.exceptions.NotSupportedError: DPY-3010: connections to this database server version are not supported by python-oracledb in thin mode
网上查过好几种写法也都报错,请问问题出在哪里了。
|
|