Salome HOME
Update copyrights
[modules/smesh.git] / src / Tools / Verima / Base / tableMailleurs.py
1 # Copyright (C) 2013-2019  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from qtsalome import QSqlQuery
21 from Base.tableDeBase import TableDeBase
22
23 class TableMailleurs (TableDeBase):
24     def __init__(self):
25         TableDeBase.__init__(self,"Mailleurs")
26         self.cols=" (nomMailleur) "
27         self.setField(("id","nomMailleur"))
28         self.setTypeField(("int","str"),('id'))
29
30     def createSqlTable(self):
31         query=QSqlQuery()
32         print("Creation de TableMailleurs", query.exec_("create table Mailleurs(id integer primary key autoincrement, nomMailleur varchar(40));"))
33
34     def dejaRemplie(self):
35         texteQuery="select * from  Mailleurs where nomMailleur='Blsurf+Ghs3D';"
36         maQuery=QSqlQuery()
37         maQuery.exec_(texteQuery)
38         nb=0
39         while(maQuery.next()): nb=nb+1
40         return nb
41
42     def remplit(self):
43         if self.dejaRemplie() :
44             print("Table Mailleurs deja initialisee")
45             return
46         self.insereLigneAutoId(('BLSURF',))
47         self.insereLigneAutoId(('NETGEN1D2D',))
48         self.insereLigneAutoId(('GHS3D+BLSURF',))
49         self.insereLigneAutoId(('GHS3D+NETGEN1D2D',))
50         self.insereLigneAutoId(('NETGEN1D2D3D',))
51
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])+ '");'
55         maQuery=QSqlQuery()
56         if debug  : print(texteQuery, " " , maQuery.exec_(texteQuery))
57         else : maQuery.exec_(texteQuery)
58
59     def getTous(self):
60         l1=[]
61         l2=[]
62         texteQuery="select * from  Mailleurs;"
63         maQuery=QSqlQuery()
64         maQuery.exec_(texteQuery)
65         while(maQuery.next()):
66             l1.append( maQuery.value(0).toInt()[0])
67             l2.append( maQuery.value(1).toString())
68         return l1,l2
69
70     def getName(self,mailleurId):
71         texteQuery="select  nomMailleur from  Mailleurs where id = " + str(mailleurId) + " ;"
72         maQuery=QSqlQuery()
73         maQuery.exec_(texteQuery)
74         while(maQuery.next()):
75             mailleurName=maQuery.value(0).toString()
76         return mailleurName