]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableQuery.py
Check In tool source code based on Build tool project revision r1655.
[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
5 # All rights reserved. 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 import Common.EdkLogger as EdkLogger
18 from Common.String import ConvertToSqlString
19 from Table import Table
20
21 ## TableQuery
22 #
23 # This class defined a table used for Query
24 #
25 # @param object: Inherited from object class
26 #
27 #
28 class TableQuery(Table):
29 def __init__(self, Cursor):
30 Table.__init__(self, Cursor)
31 self.Table = 'Query'
32
33 ## Create table
34 #
35 # Create table Query
36 #
37 # @param ID: ID of a Query
38 # @param Name: Modifier of a Query
39 # @param Value: Type of a Query
40 # @param Model: Model of a Query
41 #
42 def Create(self):
43 SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,
44 Name TEXT DEFAULT '',
45 Value TEXT DEFAULT '',
46 Model INTEGER DEFAULT 0
47 )""" % self.Table
48 Table.Create(self, SqlCommand)
49
50 ## Insert table
51 #
52 # Insert a record into table Query
53 #
54 # @param ID: ID of a Query
55 # @param Name: Modifier of a Query
56 # @param Value: Type of a Query
57 # @param Model: Model of a Query
58 #
59 def Insert(self, Name, Value, Model):
60 self.ID = self.ID + 1
61 SqlCommand = """insert into %s values(%s, '%s', '%s', %s)""" \
62 % (self.Table, self.ID, Name, Value, Model)
63 Table.Insert(self, SqlCommand)
64
65 return self.ID
66