]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableQuery.py
8e7d313c71e2fd0adf7bfe7fb372dcd45266dc5b
[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 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13
14 ##
15 # Import Modules
16 #
17 from __future__ import absolute_import
18 import Common.EdkLogger as EdkLogger
19 from Common.StringUtils import ConvertToSqlString
20 from Table.Table import Table
21
22 ## TableQuery
23 #
24 # This class defined a table used for Query
25 #
26 # @param object: Inherited from object class
27 #
28 #
29 class TableQuery(Table):
30 def __init__(self, Cursor):
31 Table.__init__(self, Cursor)
32 self.Table = 'Query'
33
34 ## Create table
35 #
36 # Create table Query
37 #
38 # @param ID: ID of a Query
39 # @param Name: Name of a Query
40 # @param Modifer: Modifier of a Query
41 # @param Value: Type of a Query
42 # @param Model: Model of a Query
43 #
44 def Create(self):
45 SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,
46 Name TEXT DEFAULT '',
47 Modifier TEXT DEFAULT '',
48 Value TEXT DEFAULT '',
49 Model INTEGER DEFAULT 0
50 )""" % self.Table
51 Table.Create(self, SqlCommand)
52
53 ## Insert table
54 #
55 # Insert a record into table Query
56 #
57 # @param ID: ID of a Query
58 # @param Name: Name of a Query
59 # @param Modifier: Modifier of a Query
60 # @param Value: Value of a Query
61 # @param Model: Model of a Query
62 #
63 def Insert(self, Name, Modifier, Value, Model):
64 self.ID = self.ID + 1
65 SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', %s)""" \
66 % (self.Table, self.ID, Name, Modifier, Value, Model)
67 Table.Insert(self, SqlCommand)
68
69 return self.ID