]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableFdf.py
2 # This file is used to create/update/query/erase table for fdf datas
4 # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
11 from __future__
import absolute_import
12 import Common
.EdkLogger
as EdkLogger
13 import CommonDataClass
.DataClass
as DataClass
14 from Table
.Table
import Table
15 from Common
.StringUtils
import ConvertToSqlString
19 # This class defined a table used for data model
21 # @param object: Inherited from object class
24 class TableFdf(Table
):
25 def __init__(self
, Cursor
):
26 Table
.__init
__(self
, Cursor
)
33 # @param ID: ID of a Fdf item
34 # @param Model: Model of a Fdf item
35 # @param Value1: Value1 of a Fdf item
36 # @param Value2: Value2 of a Fdf item
37 # @param Value3: Value3 of a Fdf item
38 # @param Arch: Arch of a Fdf item
39 # @param BelongsToItem: The item belongs to which another item
40 # @param BelongsToFile: The item belongs to which fdf file
41 # @param StartLine: StartLine of a Fdf item
42 # @param StartColumn: StartColumn of a Fdf item
43 # @param EndLine: EndLine of a Fdf item
44 # @param EndColumn: EndColumn of a Fdf item
45 # @param Enabled: If this item enabled
48 SqlCommand
= """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
49 Model INTEGER NOT NULL,
50 Value1 VARCHAR NOT NULL,
55 BelongsToItem SINGLE NOT NULL,
56 BelongsToFile SINGLE NOT NULL,
57 StartLine INTEGER NOT NULL,
58 StartColumn INTEGER NOT NULL,
59 EndLine INTEGER NOT NULL,
60 EndColumn INTEGER NOT NULL,
61 Enabled INTEGER DEFAULT 0
63 Table
.Create(self
, SqlCommand
)
67 # Insert a record into table Fdf
69 # @param ID: ID of a Fdf item
70 # @param Model: Model of a Fdf item
71 # @param Value1: Value1 of a Fdf item
72 # @param Value2: Value2 of a Fdf item
73 # @param Value3: Value3 of a Fdf item
74 # @param Arch: Arch of a Fdf item
75 # @param BelongsToItem: The item belongs to which another item
76 # @param BelongsToFile: The item belongs to which fdf file
77 # @param StartLine: StartLine of a Fdf item
78 # @param StartColumn: StartColumn of a Fdf item
79 # @param EndLine: EndLine of a Fdf item
80 # @param EndColumn: EndColumn of a Fdf item
81 # @param Enabled: If this item enabled
83 def Insert(self
, Model
, Value1
, Value2
, Value3
, Scope1
, Scope2
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
):
85 (Value1
, Value2
, Value3
, Scope1
, Scope2
) = ConvertToSqlString((Value1
, Value2
, Value3
, Scope1
, Scope2
))
86 SqlCommand
= """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
87 % (self
.Table
, self
.ID
, Model
, Value1
, Value2
, Value3
, Scope1
, Scope2
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
)
88 Table
.Insert(self
, SqlCommand
)
94 # @param Model: The Model of Record
96 # @retval: A recordSet of all found records
98 def Query(self
, Model
):
99 SqlCommand
= """select ID, Value1, Value2, Value3, Scope1, Scope2, BelongsToItem, BelongsToFile, StartLine from %s
101 and Enabled > -1""" % (self
.Table
, Model
)
102 EdkLogger
.debug(4, "SqlCommand: %s" % SqlCommand
)
103 self
.Cur
.execute(SqlCommand
)
104 return self
.Cur
.fetchall()