]>
Commit | Line | Data |
---|---|---|
30fdf114 LG |
1 | ## @file\r |
2 | # This file is used to create/update/query/erase table for Queries\r | |
3 | #\r | |
40d841f6 LG |
4 | # Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>\r |
5 | # This program and the accompanying materials\r | |
30fdf114 LG |
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 | |
17 | import Common.EdkLogger as EdkLogger\r | |
18 | from Common.String import ConvertToSqlString\r | |
19 | from Table import Table\r | |
20 | \r | |
21 | ## TableQuery\r | |
22 | #\r | |
23 | # This class defined a table used for Query\r | |
52302d4d | 24 | #\r |
30fdf114 LG |
25 | # @param object: Inherited from object class\r |
26 | #\r | |
27 | #\r | |
28 | class TableQuery(Table):\r | |
29 | def __init__(self, Cursor):\r | |
30 | Table.__init__(self, Cursor)\r | |
31 | self.Table = 'Query'\r | |
52302d4d | 32 | \r |
30fdf114 LG |
33 | ## Create table\r |
34 | #\r | |
35 | # Create table Query\r | |
36 | #\r | |
37 | # @param ID: ID of a Query\r | |
52302d4d LG |
38 | # @param Name: Name of a Query\r |
39 | # @param Modifer: Modifier of a Query\r | |
30fdf114 LG |
40 | # @param Value: Type of a Query\r |
41 | # @param Model: Model of a Query\r | |
42 | #\r | |
43 | def Create(self):\r | |
44 | SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,\r | |
45 | Name TEXT DEFAULT '',\r | |
52302d4d | 46 | Modifier TEXT DEFAULT '',\r |
30fdf114 LG |
47 | Value TEXT DEFAULT '',\r |
48 | Model INTEGER DEFAULT 0\r | |
49 | )""" % self.Table\r | |
50 | Table.Create(self, SqlCommand)\r | |
51 | \r | |
52 | ## Insert table\r | |
53 | #\r | |
54 | # Insert a record into table Query\r | |
55 | #\r | |
56 | # @param ID: ID of a Query\r | |
52302d4d LG |
57 | # @param Name: Name of a Query\r |
58 | # @param Modifier: Modifier of a Query\r | |
59 | # @param Value: Value of a Query\r | |
30fdf114 LG |
60 | # @param Model: Model of a Query\r |
61 | #\r | |
52302d4d | 62 | def Insert(self, Name, Modifier, Value, Model):\r |
30fdf114 | 63 | self.ID = self.ID + 1\r |
52302d4d LG |
64 | SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', %s)""" \\r |
65 | % (self.Table, self.ID, Name, Modifier, Value, Model)\r | |
30fdf114 LG |
66 | Table.Insert(self, SqlCommand)\r |
67 | \r | |
68 | return self.ID\r |