Salome HOME
Copyright update 2020
[modules/smesh.git] / src / Tools / Verima / Base / tableVersions.py
1 # Copyright (C) 2013-2020  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 TableVersions (TableDeBase):
24     def __init__(self):
25         TableDeBase.__init__(self,"Versions")
26         self.setField(("id","nomVersion","commentaire"))
27         self.setTypeField(('int','str','str'),('id',))
28         self.cols=" (nomVersion, commentaire) "
29
30     def createSqlTable(self):
31         query=QSqlQuery()
32         texteQuery ="create table Versions(id integer primary key autoincrement, nomVersion varchar(10),"
33         texteQuery+="commentaire varchar(30));"
34         print("Creation de TableVersions : " , query.exec_(texteQuery))
35
36
37     def remplit(self):
38         self.insereLigneAutoId(('Salome7.2.0',''))
39         self.insereLigneAutoId(('Salome7.3.0',''))
40         self.insereLigneAutoId(('Salome7.4.0',''))
41
42     def creeVersion(self,version,commentaire=""):
43         self.insereLigneAutoId((version,commentaire))
44
45
46     def chercheVersion(self,version):
47         query=QSqlQuery()
48         version=str(version)
49         if bool(version) == True :
50             texteQuery ="select id, nomVersion from Versions where id = " + str(version) +";"
51         else:
52             texteQuery ="select id, nomVersion from Versions where nomVersion ='" + version +"' ;"
53         query.exec_(texteQuery)
54         nb=0
55         while(query.next()):
56             nb=nb+1
57             id=query.value(0).toInt()[0]
58             nom=query.value(1).toString()
59         if nb != 1 : return 0, 0, ""
60         return  1, id, nom