1 # Copyright (C) 2013-2019 CEA/DEN, 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 TableMailleurs (TableDeBase):
25 TableDeBase.__init__(self,"Mailleurs")
26 self.cols=" (nomMailleur) "
27 self.setField(("id","nomMailleur"))
28 self.setTypeField(("int","str"),('id'))
30 def createSqlTable(self):
32 print("Creation de TableMailleurs", query.exec_("create table Mailleurs(id integer primary key autoincrement, nomMailleur varchar(40));"))
34 def dejaRemplie(self):
35 texteQuery="select * from Mailleurs where nomMailleur='Blsurf+Ghs3D';"
37 maQuery.exec_(texteQuery)
39 while(maQuery.next()): nb=nb+1
43 if self.dejaRemplie() :
44 print("Table Mailleurs deja initialisee")
46 self.insereLigneAutoId(('BLSURF',))
47 self.insereLigneAutoId(('NETGEN1D2D',))
48 self.insereLigneAutoId(('GHS3D+BLSURF',))
49 self.insereLigneAutoId(('GHS3D+NETGEN1D2D',))
50 self.insereLigneAutoId(('NETGEN1D2D3D',))
52 def insereLigneAutoId(self,valeurs,debug=False):
53 # difficulte a construire le texte avec une seule valeur
54 texteQuery='insert into Mailleurs (nomMailleur) values ("'+ str(valeurs[0])+ '");'
56 if debug : print(texteQuery, " " , maQuery.exec_(texteQuery))
57 else : maQuery.exec_(texteQuery)
62 texteQuery="select * from Mailleurs;"
64 maQuery.exec_(texteQuery)
65 while(maQuery.next()):
66 l1.append( maQuery.value(0).toInt()[0])
67 l2.append( maQuery.value(1).toString())
70 def getName(self,mailleurId):
71 texteQuery="select nomMailleur from Mailleurs where id = " + str(mailleurId) + " ;"
73 maQuery.exec_(texteQuery)
74 while(maQuery.next()):
75 mailleurName=maQuery.value(0).toString()