1 # Copyright (C) 2013-2020 EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from qtsalome import QSqlQuery
21 from Base.tableDeBase import TableDeBase
23 class TableGroupes (TableDeBase):
25 TableDeBase.__init__(self,"Groupes")
26 self.setField(('Groupe','Maillage','Version','Entite','NbEntite'))
27 self.setTypeField(('str','int','int','str','int'),('nomGroupe','idMaillage','idVersion','Entite'))
30 def createSqlTable(self):
34 texteQuery ="create table Groupes( nomGroupe varchar(40),idMaillage int, idVersion int,"
35 texteQuery+="Entite var(40), NbEntite int,"
36 texteQuery+="foreign key (idMaillage) references Maillages(id),"
37 texteQuery+="foreign key (idVersion) references Versions(id),"
38 texteQuery+="primary key (nomGroupe,idMaillage,idVersion,Entite));"
40 print("Creation de TableGroupes : ", query.exec_(texteQuery))
43 def getVal(self,nomGroupe,idMaillage,idVersion,typeMaille):
44 val=0 # Valeur si l enregistrement n existe pas
46 texteQuery ='select NbEntite from Groupes where nomGroupe ="' + nomGroupe +'"'
47 texteQuery +=' and idMaillage=' + str(idMaillage)
48 texteQuery +=' and idVersion = ' + str(idVersion)
49 texteQuery +=' and Entite ="' + str(typeMaille) + '";'
50 query.exec_(texteQuery)
51 while (query.next()) :
52 val=query.value(0).toInt()[0]
53 while (query.next()) :
54 print("plusieurs enregistrements dans groupe pour ", nomGroupe," ",str(idMaillage)," ",str(idVersion),"\n")
58 def getAllEntity(self):
60 texteQuery ="select distinct Entite from Groupes;"
61 query.exec_(texteQuery)
63 while (query.next()) :
64 maListe.append(str(query.value(0).toString()))