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