每当我尝试通过python连接到mysql时,都会出现此烦人的错误,请帮助我,请帮助我

时间:2020-10-14 19:04:22

标签: python mysql pip mysql-python mysql-connector

def project():
    import mysql.connector as mycon
    import pypng
    from PyQRCode import QRCode 
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    con=mycon.connect(host="localhost",user="clash",password=6969,database="alapan")
    cur=con.cursor()
    #MAIN PART
    while(True):
        print("""which movie do u want to watch 1.Dil Bechara 2. 3 Idiots 3.Dhammal 4.Harry Potter 5.Endgame
        Please enter your choice!""")
        ch=int(input("->"))
        mov={1:"Dil Bechara",2:"3 Idiots",3:"Dhammal",4:"Harry Potter",5:"Endgame"}
        movie=mov[ch]
        cost=250
        print("""Select City A.Kolkata B.Delhi C.Mumbai D.Bangalore E.Hyderabad""")
        ch1=input("->")
        di={'A':"KOLKATA",'B':"DELHI",'C':"MUMBAI",'D':"BANGALORE",'E':"HYDERABAD"}
        st="SELECT HALLS FROM"+str(di[ch1]+str(ch))
        cur.execute(st)
        con.commit()
        res=cur.fetchall()
        k=0
        for row in res:
            print(k,row)
            k+=1
        print("ENTER YOUR CHOICE")
        ch2=int(input("->"))
        st2="SELECT SEATS FROM "+str(di[ch1])+"WHERE HALL="+str(res[ch2])
        cur.execute(st2)
        con.commit()
        res2=cur.fetchall()
        print(res2)
        print("Please select the number of seats from the avaliable seats given above")
        ch3=int(input("->"))
        cur.execute("SELECT SEATS FROM "+str(di[ch1])+"WHERE HALL="+str(res[ch2]))
        con.commit()
        print("SELECT TIME P.MORNING Q.AFTERNOON R.NIGHT")
        ch4=input("Enter your choice")
        di2={'P':"MORNING",'Q':"AFTERNOON",'R':"NIGHT"}
        tme=di2[ch4]
        print("SELECT TIER I.BRONZE II.SILVER III.GOLD ")
        ch5=input("->")
        if ch5=='II':
            cost+=100
        elif ch5=="III":
            cost+=200
        print("Do u want to confirm ? Y/N")
        print(movie,"\n",str(di[ch1]),"\n",str(res[ch2],"\n",ch3,"\n",tme,"\n",ch5))#MOVIE,CITY,HALL,SEATS,TIME,TIER 
        ch6=input("->")
        if ch6.upper()=='Y':
            #here we have to change the seat number
            st3="SELECT SEATS FROM"+str(di[ch1]+str(ch))+"WHERE SEATS=SEATS-%d"%(ch3)
            cur.execute(st3)
            con.commit()
            if ch==1:
                url="https://in.bookmyshow.com//movies/dil-bechara/ET00098454"
            elif ch==2:
                url="https://in.bookmyshow.com/movies/3-idiots/ET00001611"
            elif ch==3:
                url="https://in.bookmyshow.com/movies/dhamaal/ET00000016"
            elif ch==4:
                url="https://in.bookmyshow.com/movies/harry-potter-and-the-deathly-hallows-part-2/ET00007363"
            else:
                url="https://in.bookmyshow.com/movies/avengers-endgame/ET00090482"
            qrc= pyqrcode.create(url) 
            print("Scan the qrcode saved un your python directory and scan to complete payment")
            qrc.svg("myqr.svg", scale = 8) 
            qrc.png('myqr.png', scale = 8)
            break
        else:
            break
    con.close()
if __name__=='__main__':
    project()

显示错误---:

Traceback (most recent call last):
  File "C:\Users\clash\AppData\Local\Programs\Python\Python38\Programs\Project.py", line 75, in <module>
    project()
  File "C:\Users\clash\AppData\Local\Programs\Python\Python38\Programs\Project.py", line 2, in project
    import mysql.connector as mycon
  File "C:\Users\clash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\__init__.py", line 37, in <module>
    from .connection import MySQLConnection
  File "C:\Users\clash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\connection.py", line 31, in <module>
    from .authentication import get_auth_plugin
  File "C:\Users\clash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\authentication.py", line 29, in <module>
    from . import errors
  File "C:\Users\clash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\errors.py", line 27, in <module>
    from . import utils
  File "C:\Users\clash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\utils.py", line 33, in <module>
    from .catch23 import struct_unpack
  File "C:\Users\clash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\catch23.py", line 26, in <module>
    from decimal import Decimal
ImportError: cannot import name 'Decimal' from 'decimal' (C:\Users\clash\AppData\Local\Programs\Python\Python38\Programs\decimal.py)

0 个答案:

没有答案