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