]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableInf.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableInf.py
1 ## @file
2 # This file is used to create/update/query/erase table for inf 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 ## TableInf
18 #
19 # This class defined a table used for data model
20 #
21 # @param object: Inherited from object class
22 #
23 #
24 class TableInf(Table):
25 def __init__(self, Cursor):
26 Table.__init__(self, Cursor)
27 self.Table = 'Inf'
28
29 ## Create table
30 #
31 # Create table Inf
32 #
33 # @param ID: ID of a Inf item
34 # @param Model: Model of a Inf item
35 # @param Value1: Value1 of a Inf item
36 # @param Value2: Value2 of a Inf item
37 # @param Value3: Value3 of a Inf item
38 # @param Value4: Value4 of a Inf item
39 # @param Value5: Value5 of a Inf item
40 # @param Arch: Arch of a Inf item
41 # @param BelongsToItem: The item belongs to which another item
42 # @param BelongsToFile: The item belongs to which dsc file
43 # @param StartLine: StartLine of a Inf item
44 # @param StartColumn: StartColumn of a Inf item
45 # @param EndLine: EndLine of a Inf item
46 # @param EndColumn: EndColumn of a Inf item
47 # @param Enabled: If this item enabled
48 #
49 def Create(self):
50 SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
51 Model INTEGER NOT NULL,
52 Value1 VARCHAR NOT NULL,
53 Value2 VARCHAR,
54 Value3 VARCHAR,
55 Value4 VARCHAR,
56 Value5 VARCHAR,
57 Arch VarCHAR,
58 BelongsToItem SINGLE NOT NULL,
59 BelongsToFile SINGLE NOT NULL,
60 StartLine INTEGER NOT NULL,
61 StartColumn INTEGER NOT NULL,
62 EndLine INTEGER NOT NULL,
63 EndColumn INTEGER NOT NULL,
64 Enabled INTEGER DEFAULT 0
65 )""" % self.Table
66 Table.Create(self, SqlCommand)
67
68 ## Insert table
69 #
70 # Insert a record into table Inf
71 #
72 # @param ID: ID of a Inf item
73 # @param Model: Model of a Inf item
74 # @param Value1: Value1 of a Inf item
75 # @param Value2: Value2 of a Inf item
76 # @param Value3: Value3 of a Inf item
77 # @param Value4: Value4 of a Inf item
78 # @param Value5: Value5 of a Inf item
79 # @param Arch: Arch of a Inf item
80 # @param BelongsToItem: The item belongs to which another item
81 # @param BelongsToFile: The item belongs to which dsc file
82 # @param StartLine: StartLine of a Inf item
83 # @param StartColumn: StartColumn of a Inf item
84 # @param EndLine: EndLine of a Inf item
85 # @param EndColumn: EndColumn of a Inf item
86 # @param Enabled: If this item enabled
87 #
88 def Insert(self, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):
89 self.ID = self.ID + 1
90 (Value1, Value2, Value3, Value4, Value5, Arch) = ConvertToSqlString((Value1, Value2, Value3, Value4, Value5, Arch))
91 SqlCommand = """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
92 % (self.Table, self.ID, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled)
93 Table.Insert(self, SqlCommand)
94
95 return self.ID
96
97 ## Query table
98 #
99 # @param Model: The Model of Record
100 #
101 # @retval: A recordSet of all found records
102 #
103 def Query(self, Model):
104 SqlCommand = """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
105 where Model = %s
106 and Enabled > -1""" % (self.Table, Model)
107 EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
108 self.Cur.execute(SqlCommand)
109 return self.Cur.fetchall()