Home > Mobile >  Pycharm import pymssql template error
Pycharm import pymssql template error

Time:10-21

C: \ Users \ MACHENIKE \ PycharmProjects \ untitled11 \ venv \ Scripts \ python exe C:/Users/MACHENIKE PycharmProjects untitled11/venv/Online Bookstore - Management - System - master/v1.0/Add_bookUI py
Traceback (the most recent call last) :
File "C:/Users/MACHENIKE PycharmProjects untitled11/venv/Online Bookstore - Management - System - master/v1.0/Add_bookUI py", line 2, the in & lt; module>
The import pymssql
ModuleNotFoundError: No module named 'pymssql'

The Process finished with exit code 1
 

The import sys
The import pymssql
The from PyQt5. QtCore import pyqtSignal
The from PyQt5. QtWidgets import *

Server='localhost'
User='SA'
Password='
The database='Course_Design'


The class Add_bookUI (QWidget) :
Switch_window=pyqtSignal ()

Def __init__ (self) :
Super (Add_bookUI, self) __init__ ()
The self. The initUI ()

Def initUI (self) :
# to get the data from the database
The self. The connect=pymssql. Connect (server, user, password, database) # server name, account, password and database name
The self. The cursor=self. Connect. Cursor ()

# tag
Self. Book_name_label=QLabel (" book name: ")
Self. Author_name_label=QLabel (" the author: ")
Self. Pub_house_label=QLabel (" press: ")
Self. Book_kind_label=QLabel (" books categories: ")
Self. Price_label=QLabel (" sales price:)
Self. Num_label=QLabel (" purchase number: ")

# input box
Self. Book_name_e=QLineEdit ()
Self. Author_name_e=QLineEdit ()
Self. Pub_house_e=QLineEdit ()
Self. Book_kind_e=QLineEdit ()
Self. Price_e=QLineEdit ()
Self. Num_e=QLineEdit ()
Self. Book_name_e. EditingFinished. Connect (self. Kind_is_ok)
Self. Book_name_e. EditingFinished. Connect (self. Price_is_ok)
Self. Pub_house_e. EditingFinished. Connect (self. Kind_is_ok)
Self. Pub_house_e. EditingFinished. Connect (self. Price_is_ok)
Self. Author_name_e. EditingFinished. Connect (self. Kind_is_ok)
Self. Author_name_e. EditingFinished. Connect (self. Kind_is_ok)

# button
Self. Ok_btn=QPushButton (" confirmation ")
Self. Cancel_btn=QPushButton (" cancel ")
Self. Ok_btn. Clicked. Connect (self. Order_is_ok)
Self. Cancel_btn. Clicked. Connect (self. Cancel_order)

# layout
Self. SetWindowTitle (" buy books ")
The self. The resize (300, 400)
Self center ()
The grid=QGridLayout ()
The grid. SetSpacing (10)
The grid. AddWidget (self. Book_name_label, 0, 0)
The grid. AddWidget (self. Book_name_e, 0, 1)
The grid. AddWidget (self. Author_name_label, 1, 0)
The grid. AddWidget (self. Author_name_e, 1, 1)
The grid. AddWidget (self. Pub_house_label, 2, 0)
The grid. AddWidget (self. Pub_house_e, 2, 1)
The grid. AddWidget (self. Book_kind_label, 3, 0)
The grid. AddWidget (self. Book_kind_e, 3, 1)
The grid. AddWidget (self. Price_label, 4, 0)
The grid. AddWidget (self. Price_e, 4, 1)
The grid. AddWidget (self. Num_label, 5, 0)
The grid. AddWidget (self. Num_e, 5, 1)
Grid. AddWidget (self cancel_btn, 6, 0)
Grid. AddWidget (self ok_btn, 6, 1)
Self. SetLayout (grid)
The self. The show ()

Def center (self) :
Qr=self. FrameGeometry ()
Cp=QDesktopWidget (.) availableGeometry () center ()
Qr. MoveCenter (cp)
Self. Move (qr) topLeft ())

Def kind_is_ok (self) :
Book_name=self. Book_name_e. Text ()
Author_name=self. Author_name_e. Text ()
Pub_house=self. Pub_house_e. Text ()
SQL='select Book_kind from Book_information where Book_name=N' + "" "+ +" Book_name \ 'and Book_author=N \' "+ author_name +" \ 'and Book_Publishing_house=N \' \ '" + pub_house + ", "
The self. The cursor. The execute (SQL)
Results=self. Cursor. Fetchall ()
If len (results) & gt; 0:
Self. Book_kind_e. SetText (results [0] [0])
Self. Book_name_e. SetReadOnly (True)

Def price_is_ok (self) :
Book_name=self. Book_name_e. Text ()
Author_name=self. Author_name_e. Text ()
Pub_house=self. Pub_house_e. Text ()
SQL='select Book_price from Book_Information inner join Book_storage on Book_Information. Book_no.=Book_storage Book_no where Book_name=N' + "" "+ Book_name +" \ 'and Book_author=N \' "+ author_name +" \ 'and Book_Publishing_house=N \' \ '" + pub_house + ", "
Print (SQL)
The self. The cursor. The execute (SQL)
Results=self. Cursor. Fetchall ()
If len (results) & gt; 0:
Self. Price_e. SetText (STR (results [0] [0]))

Def order_is_ok (self) :
Book_name=self. Book_name_e. Text ()
Author_name=self. Author_name_e. Text ()
Pub_house=self. Pub_house_e. Text ()
Book_kind=self. Book_kind_e. Text ()
Book_price=self. Price_e. Text ()
Num=self. Num_e. Text ()
If book_name=="" :
QMessageBox. Critical (self, "fail", "please enter the name of the book")
Elif author_name=="" :
QMessageBox. Critical (self, "fail", "please enter the author name")
Elif pub_house=="" :
QMessageBox. Critical (self, "fail", "please enter the press information")
Elif book_price=="" :
QMessageBox. Critical (self, "fail", "please enter the book price")
Elif book_kind=="" :
QMessageBox. Critical (self, "fail", "please enter the types of books")
The else:
QMessageBox. Question (self, "alert", "identification of complete purchase cannot be changed after the operation, operation?" nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • Qt
  • Related