]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableDec.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableDec.py
1 ## @file
2 # This file is used to create/update/query/erase table for dec datas
3 #
4 # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
6 #
7
8 ##
9 # Import Modules
10 #
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
16
17 ## TableDec
18 #
19 # This class defined a table used for data model
20 #
21 # @param object: Inherited from object class
22 #
23 #
24 class TableDec(Table):
25 def __init__(self, Cursor):
26 Table.__init__(self, Cursor)
27 self.Table = 'Dec'
28
29 ## Create table
30 #
31 # Create table Dec
32 #
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
46 #
47 def Create(self):
48 SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
49 Model INTEGER NOT NULL,
50 Value1 VARCHAR NOT NULL,
51 Value2 VARCHAR,
52 Value3 VARCHAR,
53 Arch VarCHAR,
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
61 )""" % self.Table
62 Table.Create(self, SqlCommand)
63
64 ## Insert table
65 #
66 # Insert a record into table Dec
67 #
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
81 #
82 def Insert(self, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):
83 self.ID = self.ID + 1
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)
88
89 return self.ID
90
91 ## Query table
92 #
93 # @param Model: The Model of Record
94 #
95 # @retval: A recordSet of all found records
96 #
97 def Query(self, Model):
98 SqlCommand = """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
99 where Model = %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()