Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
159 views
in Technique[技术] by (71.8m points)

I tryied to in insert and select in the same time in mysql PyQt5

I tryied to in insert and select in the same time in mysql PyQt5 but the program didn't work. the program is working till i tryied to insert and selectin the same time in MySql.

This is the code before I got the issue :

        self.groupe.currentTextChanged.connect(self.grouchan)

def grouchan(self):
        global id_filint
        qidmat = "select Id_filiere from filiereacademiquecsv where Libelle_filiere_francais=%s"
        ridmat = (self.txt_filiere.text(),)
        mycursor.execute(qidmat, ridmat)
        myresult = mycursor.fetchone()
        for idf in myresult:
            id_filint = idf

        qmat = "select distinct Id_matiere from matiereunité m inner join filiereacademiquecsv f on f.Id_filiere=m.Id_filieranalytiq where Id_filieranalytiq=%s and Libelle_matiere_francais=%s"
        rnp1 = (id_filint, self.matiere.currentText())
        mycursor.execute(qmat,rnp1)
        myresult1 = mycursor.fetchone()
        for i in myresult1:
            print(i)

        qgrp = "select idgroupe from groupcyclniv where LibGroupe=%s"
        rnp3 = (self.groupe.currentText(),)
        mycursor.execute(qgrp, rnp3)
        myresult2 = mycursor.fetchone()
        for v in myresult2:
            print(v)

This is where I got the issue. This is where I tryied to insert and select :

        qnp = "insert into mobile (Id_eleve, nomprenom, Id_matiere) SELECT a.IdEleve,e.nomprenom,m.Id_matiere FROM asselevgroupevf a inner join eleve e inner join matiereunité m on a.IdEleve = e.Ideleve where a.IdGroup =%s and Id_matiere =%s"
        rnp1 = (v, i)
        mycursor.execute(rnp1, qnp)
        mydb.commit()
question from:https://stackoverflow.com/questions/65902223/i-tryied-to-in-insert-and-select-in-the-same-time-in-mysql-pyqt5

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...