bonjour,
J'ai crée un formulaire avec PyQt4 et je voudrais le relier avec sqlite3 mais je reçois l'erreur: ValueError: parameters are of unsupported type
voila mon code:
et voila le code la base de données:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 def insertDataPatient(self): Nom = self.Nom_lineEdit Prenom = self.Prenom_lineEdit Date_naissance = self.naissance_dateEdit Numero_SS = self.Numero_SS_lineEdit Telephone = self.Telephone_lineEdit Email = self.Email_lineEdit Genre = "Homme" if self.Homme_radioButton == True: Genre = "Homme" if self.Femme_radioButton == True: Genre = "Femme" Poids = self.Poids_lineEdit Taille = self.Taille_lineEdit Adresse = self.Adresse_lineEdit Docteur = self.Docteur_lineEdit Date = self.dateEdit Description = self.Description_TextEdit connection = sqlite3.connect("patient_form.db") #connection.executemany("INSERT INTO PATIENT_TAB VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)",(Nom, Prenom, Date_naissance, Numero_SS, Telephone, Email, Genre, Poids, Taille, Adresse, Docteur, Date, Description)) connection.executemany(""" INSERT INTO PATIENT_TAB(Nom, Prenom, Date_naissance, Numero_SS, Telephone, Email, Genre, Poids, Taille, Adresse, Docteur, Date, Description) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)""", (Nom, Prenom, Date_naissance, Numero_SS, Telephone, Email, Genre, Poids, Taille, Adresse, Docteur, Date, Description)) connection.commit() connection.close()
Pouvez vous m'aider svp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 import sqlite3 def createTable(): connection = sqlite3.connect('patient_form.db') connection.execute("CREATE TABLE PATIENT_TAB(Nom TEXT NOT NULL, Prenom TEXT NOT NULL, Date_naissance INTEGER, Numero_SS TEXT NOT NULL, Telephone TEXT, Email TEXT, Genre TEXT, Poids TEXT, Taille TEXT, Adresse TEXT, Docteur TEXT, Date INTEGER, Description TEXT)") #connection.execute("INSERT INTO PATIENT_TAB VALUES(?,?,?)",('ajayssj4','ajay@gmail.com','ajayajay')) connection.commit() result = connection.execute("SELECT * FROM PATIENT_TAB") for data in result: print("Nom : ",data[0]) print("Prenom : ",data[1]) print("Date_naissance :",data[2]) print("Numero_SS : ",data[3]) print("Telephone : ",data[4]) print("Email :",data[5]) print("Genre : ",data[6]) print("Poids : ",data[7]) print("Taille :",data[8]) print("Adresse : ",data[9]) print("Docteur : ",data[10]) print("Date :",data[11]) print("Description :",data[12]) connection.close() createTable()
Merci.
Partager