]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableDec.py
2 # This file is used to create/update/query/erase table for dec datas
4 # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
11 from __future__
import absolute_import
12 import Common
.EdkLogger
as EdkLogger
13 import CommonDataClass
.DataClass
as DataClass
14 from Table
.Table
import Table
15 from Common
.StringUtils
import ConvertToSqlString
19 # This class defined a table used for data model
21 # @param object: Inherited from object class
24 class TableDec(Table
):
25 def __init__(self
, Cursor
):
26 Table
.__init
__(self
, Cursor
)
33 # @param ID: ID of a Dec item
34 # @param Model: Model of a Dec item
35 # @param Value1: Value1 of a Dec item
36 # @param Value2: Value2 of a Dec item
37 # @param Value3: Value3 of a Dec item
38 # @param Arch: Arch of a Dec item
39 # @param BelongsToItem: The item belongs to which another item
40 # @param BelongsToFile: The item belongs to which dsc file
41 # @param StartLine: StartLine of a Dec item
42 # @param StartColumn: StartColumn of a Dec item
43 # @param EndLine: EndLine of a Dec item
44 # @param EndColumn: EndColumn of a Dec item
45 # @param Enabled: If this item enabled
48 SqlCommand
= """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
49 Model INTEGER NOT NULL,
50 Value1 VARCHAR NOT NULL,
54 BelongsToItem SINGLE NOT NULL,
55 BelongsToFile SINGLE NOT NULL,
56 StartLine INTEGER NOT NULL,
57 StartColumn INTEGER NOT NULL,
58 EndLine INTEGER NOT NULL,
59 EndColumn INTEGER NOT NULL,
60 Enabled INTEGER DEFAULT 0
62 Table
.Create(self
, SqlCommand
)
66 # Insert a record into table Dec
68 # @param ID: ID of a Dec item
69 # @param Model: Model of a Dec item
70 # @param Value1: Value1 of a Dec item
71 # @param Value2: Value2 of a Dec item
72 # @param Value3: Value3 of a Dec item
73 # @param Arch: Arch of a Dec item
74 # @param BelongsToItem: The item belongs to which another item
75 # @param BelongsToFile: The item belongs to which dsc file
76 # @param StartLine: StartLine of a Dec item
77 # @param StartColumn: StartColumn of a Dec item
78 # @param EndLine: EndLine of a Dec item
79 # @param EndColumn: EndColumn of a Dec item
80 # @param Enabled: If this item enabled
82 def Insert(self
, Model
, Value1
, Value2
, Value3
, Value4
, Value5
, Arch
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
):
84 (Value1
, Value2
, Value3
, Arch
) = ConvertToSqlString((Value1
, Value2
, Value3
, Arch
))
85 SqlCommand
= """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
86 % (self
.Table
, self
.ID
, Model
, Value1
, Value2
, Value3
, Arch
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
)
87 Table
.Insert(self
, SqlCommand
)
93 # @param Model: The Model of Record
95 # @retval: A recordSet of all found records
97 def Query(self
, Model
):
98 SqlCommand
= """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
100 and Enabled > -1""" % (self
.Table
, Model
)
101 EdkLogger
.debug(4, "SqlCommand: %s" % SqlCommand
)
102 self
.Cur
.execute(SqlCommand
)
103 return self
.Cur
.fetchall()