]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableDsc.py
1 from __future__
import absolute_import
3 # This file is used to create/update/query/erase table for dsc datas
5 # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 import Common
.EdkLogger
as EdkLogger
19 import CommonDataClass
.DataClass
as DataClass
20 from Table
.Table
import Table
21 from Common
.StringUtils
import ConvertToSqlString
25 # This class defined a table used for data model
27 # @param object: Inherited from object class
30 class TableDsc(Table
):
31 def __init__(self
, Cursor
):
32 Table
.__init
__(self
, Cursor
)
39 # @param ID: ID of a Dsc item
40 # @param Model: Model of a Dsc item
41 # @param Value1: Value1 of a Dsc item
42 # @param Value2: Value2 of a Dsc item
43 # @param Value3: Value3 of a Dsc item
44 # @param Arch: Arch of a Dsc item
45 # @param BelongsToItem: The item belongs to which another item
46 # @param BelongsToFile: The item belongs to which dsc file
47 # @param StartLine: StartLine of a Dsc item
48 # @param StartColumn: StartColumn of a Dsc item
49 # @param EndLine: EndLine of a Dsc item
50 # @param EndColumn: EndColumn of a Dsc item
51 # @param Enabled: If this item enabled
54 SqlCommand
= """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
55 Model INTEGER NOT NULL,
56 Value1 VARCHAR NOT NULL,
60 BelongsToItem SINGLE NOT NULL,
61 BelongsToFile SINGLE NOT NULL,
62 StartLine INTEGER NOT NULL,
63 StartColumn INTEGER NOT NULL,
64 EndLine INTEGER NOT NULL,
65 EndColumn INTEGER NOT NULL,
66 Enabled INTEGER DEFAULT 0
68 Table
.Create(self
, SqlCommand
)
72 # Insert a record into table Dsc
74 # @param ID: ID of a Dsc item
75 # @param Model: Model of a Dsc item
76 # @param Value1: Value1 of a Dsc item
77 # @param Value2: Value2 of a Dsc item
78 # @param Value3: Value3 of a Dsc item
79 # @param Arch: Arch of a Dsc item
80 # @param BelongsToItem: The item belongs to which another item
81 # @param BelongsToFile: The item belongs to which dsc file
82 # @param StartLine: StartLine of a Dsc item
83 # @param StartColumn: StartColumn of a Dsc item
84 # @param EndLine: EndLine of a Dsc item
85 # @param EndColumn: EndColumn of a Dsc item
86 # @param Enabled: If this item enabled
88 def Insert(self
, Model
, Value1
, Value2
, Value3
, Arch
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
):
90 (Value1
, Value2
, Value3
, Arch
) = ConvertToSqlString((Value1
, Value2
, Value3
, Arch
))
91 SqlCommand
= """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
92 % (self
.Table
, self
.ID
, Model
, Value1
, Value2
, Value3
, Arch
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
)
93 Table
.Insert(self
, SqlCommand
)
99 # @param Model: The Model of Record
101 # @retval: A recordSet of all found records
103 def Query(self
, Model
):
104 SqlCommand
= """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
106 and Enabled > -1""" % (self
.Table
, Model
)
107 EdkLogger
.debug(4, "SqlCommand: %s" % SqlCommand
)
108 self
.Cur
.execute(SqlCommand
)
109 return self
.Cur
.fetchall()