]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableQuery.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableQuery.py
1 ## @file
2 # This file is used to create/update/query/erase table for Queries
3 #
4 # Copyright (c) 2008, 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 from Common.StringUtils import ConvertToSqlString
14 from Table.Table import Table
15
16 ## TableQuery
17 #
18 # This class defined a table used for Query
19 #
20 # @param object: Inherited from object class
21 #
22 #
23 class TableQuery(Table):
24 def __init__(self, Cursor):
25 Table.__init__(self, Cursor)
26 self.Table = 'Query'
27
28 ## Create table
29 #
30 # Create table Query
31 #
32 # @param ID: ID of a Query
33 # @param Name: Name of a Query
34 # @param Modifier: Modifier of a Query
35 # @param Value: Type of a Query
36 # @param Model: Model of a Query
37 #
38 def Create(self):
39 SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,
40 Name TEXT DEFAULT '',
41 Modifier TEXT DEFAULT '',
42 Value TEXT DEFAULT '',
43 Model INTEGER DEFAULT 0
44 )""" % self.Table
45 Table.Create(self, SqlCommand)
46
47 ## Insert table
48 #
49 # Insert a record into table Query
50 #
51 # @param ID: ID of a Query
52 # @param Name: Name of a Query
53 # @param Modifier: Modifier of a Query
54 # @param Value: Value of a Query
55 # @param Model: Model of a Query
56 #
57 def Insert(self, Name, Modifier, Value, Model):
58 self.ID = self.ID + 1
59 SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', %s)""" \
60 % (self.Table, self.ID, Name, Modifier, Value, Model)
61 Table.Insert(self, SqlCommand)
62
63 return self.ID