]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Table/TableInf.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableInf.py
CommitLineData
30fdf114
LG
1## @file\r
2# This file is used to create/update/query/erase table for inf datas\r
3#\r
f7496d71 4# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
2e351cbe 5# SPDX-License-Identifier: BSD-2-Clause-Patent\r
30fdf114
LG
6#\r
7\r
8##\r
9# Import Modules\r
10#\r
1ccc4d89 11from __future__ import absolute_import\r
30fdf114
LG
12import Common.EdkLogger as EdkLogger\r
13import CommonDataClass.DataClass as DataClass\r
855698fb 14from Table.Table import Table\r
5a57246e 15from Common.StringUtils import ConvertToSqlString\r
30fdf114
LG
16\r
17## TableInf\r
18#\r
19# This class defined a table used for data model\r
f7496d71 20#\r
30fdf114
LG
21# @param object: Inherited from object class\r
22#\r
23#\r
24class TableInf(Table):\r
25 def __init__(self, Cursor):\r
26 Table.__init__(self, Cursor)\r
27 self.Table = 'Inf'\r
f7496d71 28\r
30fdf114
LG
29 ## Create table\r
30 #\r
31 # Create table Inf\r
32 #\r
33 # @param ID: ID of a Inf item\r
34 # @param Model: Model of a Inf item\r
35 # @param Value1: Value1 of a Inf item\r
36 # @param Value2: Value2 of a Inf item\r
37 # @param Value3: Value3 of a Inf item\r
38 # @param Value4: Value4 of a Inf item\r
39 # @param Value5: Value5 of a Inf item\r
40 # @param Arch: Arch of a Inf item\r
41 # @param BelongsToItem: The item belongs to which another item\r
42 # @param BelongsToFile: The item belongs to which dsc file\r
43 # @param StartLine: StartLine of a Inf item\r
44 # @param StartColumn: StartColumn of a Inf item\r
45 # @param EndLine: EndLine of a Inf item\r
46 # @param EndColumn: EndColumn of a Inf item\r
47 # @param Enabled: If this item enabled\r
48 #\r
49 def Create(self):\r
50 SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,\r
51 Model INTEGER NOT NULL,\r
52 Value1 VARCHAR NOT NULL,\r
53 Value2 VARCHAR,\r
54 Value3 VARCHAR,\r
55 Value4 VARCHAR,\r
56 Value5 VARCHAR,\r
57 Arch VarCHAR,\r
58 BelongsToItem SINGLE NOT NULL,\r
59 BelongsToFile SINGLE NOT NULL,\r
60 StartLine INTEGER NOT NULL,\r
61 StartColumn INTEGER NOT NULL,\r
62 EndLine INTEGER NOT NULL,\r
63 EndColumn INTEGER NOT NULL,\r
64 Enabled INTEGER DEFAULT 0\r
65 )""" % self.Table\r
66 Table.Create(self, SqlCommand)\r
67\r
68 ## Insert table\r
69 #\r
70 # Insert a record into table Inf\r
71 #\r
72 # @param ID: ID of a Inf item\r
73 # @param Model: Model of a Inf item\r
74 # @param Value1: Value1 of a Inf item\r
75 # @param Value2: Value2 of a Inf item\r
76 # @param Value3: Value3 of a Inf item\r
77 # @param Value4: Value4 of a Inf item\r
78 # @param Value5: Value5 of a Inf item\r
79 # @param Arch: Arch of a Inf item\r
80 # @param BelongsToItem: The item belongs to which another item\r
81 # @param BelongsToFile: The item belongs to which dsc file\r
82 # @param StartLine: StartLine of a Inf item\r
83 # @param StartColumn: StartColumn of a Inf item\r
84 # @param EndLine: EndLine of a Inf item\r
85 # @param EndColumn: EndColumn of a Inf item\r
86 # @param Enabled: If this item enabled\r
87 #\r
88 def Insert(self, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):\r
89 self.ID = self.ID + 1\r
90 (Value1, Value2, Value3, Value4, Value5, Arch) = ConvertToSqlString((Value1, Value2, Value3, Value4, Value5, Arch))\r
91 SqlCommand = """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \\r
92 % (self.Table, self.ID, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled)\r
93 Table.Insert(self, SqlCommand)\r
f7496d71 94\r
30fdf114 95 return self.ID\r
f7496d71 96\r
30fdf114
LG
97 ## Query table\r
98 #\r
f7496d71 99 # @param Model: The Model of Record\r
30fdf114 100 #\r
f7496d71 101 # @retval: A recordSet of all found records\r
30fdf114
LG
102 #\r
103 def Query(self, Model):\r
104 SqlCommand = """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s\r
105 where Model = %s\r
106 and Enabled > -1""" % (self.Table, Model)\r
107 EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)\r
108 self.Cur.execute(SqlCommand)\r
109 return self.Cur.fetchall()\r